Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Thanked 2 Times in 2 Posts

    Session not being remembered

    I'm finding that sessions get deleted after the browser is closed (or after some time), despite using:


    Any ideas why?

    This is in the latest version of Firefox.

    if ($ENV{'QUERY_STRING'} eq "Afrow UK") {
    print "$ENV{'QUERY_STRING'} rocks!";
    } else {
    print qq~$ENV{'QUERY_STRING'} sucks :)~;

  2. #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Denver, Colorado USA
    Thanked 506 Times in 494 Posts
    Assuming that sessions are functioning using cookies to store the session ID (session_start is actually creating/restarting a session and you can browse between pages and access session variables) there are two things (three if you count code that deliberately destroys a session) that can cause a session to be deleted. The session cookie lifetime (which the code you posted should be taking care of) and session data garbage collection.

    Have you determined that the session cookie exists in the cookie folder after the browser is closed?

    If your web server is busy or you are on a busy shared hosting web server and/or someone has set a small garbage collection max life time (you won't believe how many times I have seen posts where someone wants to use a short garbage collection time to log people out instead of using proper code), you will see any session data files that are older than session.gc_maxlifetime being deleted every session.gc_probability/session.gc_divisor session_start() statements.
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

  3. #3
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Copenhagen, Denmark
    Thanked 5 Times in 5 Posts
    I have no idea why. What have you done to debug?

    When it comes to cookies I find the LiveHTTPHeaders extension for Firefox invaluable. Have you tried that? You should be able to clearly see the cookie parameters being sent via the HTTP header.

    Also I use the Web Developer Extension for Firefox. This provides a better interface for viewing/deleting cookies.

    Context: CFMaBiSmAd posted while I was writing this.


Posting Permissions

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