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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cookie gets deleted when the browser closes.

    Whenever I close my browser the cookie gets deleted for some reason. Here's the code I use to set the cookie:

    setcookie('sitename', "$uname2,$pword2", time()+2147483647);

    I'm not using sessions or anything so I don't understand why this is happening. It happens in Firefox and IE so it's not browser related like I thought. I figured there must be a stupid mistake with how I'm setting it.

    If you need more code let me know, but that should be the only relevant part pertaining to cookies.

    Thanks

    Edited:

    I found the problem myself already. On my home install of apache/php the session.cookie_lifetime was set to 0. It worked fine on my remote server so I figured it had something to do with my apache/php configuration.

    I didn't see a way to close this so I just added the solution for anyone else that searchs for the same problem.
    Last edited by Username; 09-24-2005 at 11:18 AM.

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think its becuase of the ammount of time you are trying to set the cookie for (68 years). I usually set cookies for no more than a year.... I always use an exact value by doing multiplication:

    PHP Code:
    $cookietime time()+(60*60*24*365); 
    this always works fine, i did try multiplying this by 100 though as a test, and I encountered the same problem as you.


  •  

    Posting Permissions

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