SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot rrreview's Avatar
    Join Date
    Jul 2002
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Question about deleting cookies

    I've looked all over php.net and couldn't find any kind of function for deleting cookies. What I've done is create a login system that sets a cookie (I'll show the code below) with a certain amount of time before it expires. What I want to do is have a sign off link, so when you click it, it deletes the cookie or ends the session.
    PHP Code:
    setcookie("mycookievalue""TRUE"time()+(3600 24)); 
    That's the code in my login.php script. My index.php script checks to see if that cookie exists with an if statement. Thanks for any help.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To delete a COOKIE just give it a time/date in the past; ie older than the current time As simple as that really, and it'll die a horrible death...

  3. #3
    lean mean coding machine cosmo's Avatar
    Join Date
    Aug 2001
    Location
    the cosmos
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For example:

    PHP Code:

    setcookie
    ("mycookievalue"""time()-9999); 
    Luthfur R. - Web Developer
    PHP Lite.com - Professional PHP Scripts and Web Applications
    Calendar Express 2 - Web Based Calendar and Event Publishing System

  4. #4
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/function.setcookie.php

    "Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string (""), and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client."

  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What more can we say...

  6. #6
    SitePoint Zealot rrreview's Avatar
    Join Date
    Jul 2002
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Such great helpers. If I could give you an upload queue score like on eMule, damnit I would! Thank you all. It works like a charm.


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
  •