Results 1 to 2 of 2

Thread: Arg, WHY IT NO DELETE COOKIE!? [resolved]

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Arg, WHY IT NO DELETE COOKIE!? [resolved]

    PHP Code:
    <?
    if ($delete)
    {
        setcookie($name, "", time() - 3600); // Setting to the past deletes
    }
    else
    {
        setcookie($name, "");
    }
    header("Location: " . $returnto);
    exit;
    ?>
    The file is called setcookie.php.

    The user clicks a link with the URL setcookie.php?name=skipflashintro&delete=true&returnto=index2.php . But the cookie stays there. The cookie was made using setcookie.php?name=skipflashintro&delete=false&returnto=index2.php . So why doesn't it get deleted!?
    Last edited by filburt1; Feb 20th, 2002 at 10:19 PM.

  2. #2

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    NM, it was my crappy list-all-the-cookies code. Here's a working version if anybody cares:
    PHP Code:
    $allcookies array_keys($HTTP_COOKIE_VARS);
    $allcookievalues array_values($HTTP_COOKIE_VARS);
    if (
    sizeof($allcookies) == 0)
    {
        echo 
    "<br><br>TurtleTips hasn't put any cookies on your system.";
    }
    else
    {
        echo 
    "<ul>";
        for (
    $i 0$i sizeof($allcookies); $i++)
        {
            echo 
    "<li><b>" $allcookies[$i] . "</b> containing <b>" $allcookievalues[$i] . "</b>";
            echo 
    " (<a href=\"setcookie.php?name=";
            echo 
    $allcookies[$i];
            echo 
    "&delete=true&returnto=";
            echo 
    $PHP_SELF;
            echo 
    "\">delete</a>)</li>\n";
        }
        echo 
    "</ul>";


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width