SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: delete a cookie

  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    delete a cookie

    Code:
    <?php
    $cookieName='myCookie';
    $cookieValue='myValue';
    $myDomain='dot.kr';
    setcookie($cookieName, $cookieValue, 0, "/", " .$myDomain");
    ?>
    How can I delete the cookie which is set by the code above?

  2. #2
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Setting its expiration to some time in the past should clear it:

    setcookie("myCookie",$cookievalue,time()-10);

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    Also note that this will only clear the cookie for the NEXT pageload. You may also want to clear out the $_COOKIE array if you want to get rid of information from the current pageload.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

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