Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to clear cookies using PHP

    Hi friends,

    I have set cookies using setcookies. I want to clear them when user click on sigh out link. Please guide me how can i do this.

    Thanks,

    Ali.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,041
    Thanks
    19
    Thanked 42 Times in 42 Posts
    www.php.net/setcookie
    PHP Code:
    setcookie ("TestCookie"""time() - 3600);// set the time to minus to remove the cookie. 

  • Users who have thanked rafiki for this post:

    garrisonian14 (05-27-2008)

  • #3
    New Coder
    Join Date
    Nov 2007
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your reply.

  • #4
    Regular Coder
    Join Date
    Apr 2006
    Posts
    186
    Thanks
    21
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by rafiki View Post
    www.php.net/setcookie
    PHP Code:
    setcookie ("TestCookie"""time() - 3600);// set the time to minus to remove the cookie. 
    Was wondering why in PHP most people seem to set -3600 seconds, is there any advantage of using it over -1 second? Most JavaScripts seem to use -1 while PHP uses -3600 more.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    http://www.phpbuddy.com/article.php?id=12

    Read the part about deleting cookies.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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