Problems with session...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jodleren

    Problems with session...

    Hi

    I am wondering what goes wrong...
    I have

    session_cache_e xpire(30);
    session_start() ;

    How can I check whether the _last_ session (from e.g. yesterday) has
    ended?
    My problem is, that once logged in, it remembers it forever. All
    $_SESSION variables will stay and will confuse my software next time
    they open a browser again, as it can see that the $_SESSION data are
    still present...
    Is there a way to get to know, that the session has ended, or the
    browser has been closed?

    WBR
    Sonnich

  • Erwin Moller

    #2
    Re: Problems with session...

    jodleren schreef:
    Hi
    >
    Hi Jodleren,
    I am wondering what goes wrong...
    I have
    >
    session_cache_e xpire(30);
    session_start() ;
    >
    How can I check whether the _last_ session (from e.g. yesterday) has
    ended?
    You cannot, unless you use own sessionhandlers .


    My problem is, that once logged in, it remembers it forever. All
    $_SESSION variables will stay and will confuse my software next time
    they open a browser again, as it can see that the $_SESSION data are
    still present...
    Possibly this happens because nobody else use that site.
    Sessions are destroyed besaed on a random generator.

    On the top of my head it is dafault configured with a chance of 1/100
    the system will check for stale sessions.
    This means that EVERY request to PHP has a 1/100 chance of firing the
    session-garbage collection.

    Check you php.ini for excact sessting (or use phpinfo()).

    Is there a way to get to know, that the session has ended, or the
    browser has been closed?
    Browser close? No.
    Session ended? Yes, with proper session_save_ha ndler (via a db eg).

    Regards,
    Erwin Moller
    >
    WBR
    Sonnich
    >

    --
    "There are two ways of constructing a software design: One way is to
    make it so simple that there are obviously no deficiencies, and the
    other way is to make it so complicated that there are no obvious
    deficiencies. The first method is far more difficult."
    -- C.A.R. Hoare

    Comment

    • C. (http://symcbean.blogspot.com/)

      #3
      Re: Problems with session...

      On 22 Oct, 16:33, Erwin Moller
      <Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
      jodleren schreef:
      >
      Hi
      >
      Hi Jodleren,
      >
      I am wondering what goes wrong...
      I have
      >
      session_cache_e xpire(30);
      session_start() ;
      >
      How can I check whether the _last_ session (from e.g. yesterday) has
      ended?
      >
      You cannot, unless you use own sessionhandlers .
      >
      You can't have a session without using a session handler. You can roll
      your own, but there's no need. The default session handler just uses
      files - see session.save_pa th for the directory. To find out when the
      session was last used check the mtime (or the atime - but that may
      have been updated by backup software etc).
      >
      Possibly this happens because nobody else use that site.
      Sessions are destroyed besaed on a random generator.
      >
      Note that the session will be considered closed if its not accessed
      after session.gc_maxl ifetime, even thought the file may still persist.
      Its only cleaned up when the housekeeping job kicks in (based on a
      dice throw when any session_start using the same handler is called for
      any session).

      C.

      Comment

      • Erwin Moller

        #4
        Re: Problems with session...

        C. (http://symcbean.blogspot.com/) schreef:
        On 22 Oct, 16:33, Erwin Moller
        <Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
        >jodleren schreef:
        >>
        >>Hi
        >Hi Jodleren,
        >>
        >>I am wondering what goes wrong...
        >>I have
        >> session_cache_e xpire(30);
        >> session_start() ;
        >>How can I check whether the _last_ session (from e.g. yesterday) has
        >>ended?
        >You cannot, unless you use own sessionhandlers .
        >>
        >
        You can't have a session without using a session handler. You can roll
        your own, but there's no need. The default session handler just uses
        files - see session.save_pa th for the directory. To find out when the
        session was last used check the mtime (or the atime - but that may
        have been updated by backup software etc).
        >
        >Possibly this happens because nobody else use that site.
        >Sessions are destroyed besaed on a random generator.
        >>
        >
        Note that the session will be considered closed if its not accessed
        after session.gc_maxl ifetime, even thought the file may still persist.
        Its only cleaned up when the housekeeping job kicks in (based on a
        dice throw when any session_start using the same handler is called for
        any session).
        That is not true C,
        I find my sessions just alive an kicking after a day (or 2 in this case).
        My session.gc_maxl ifetime = 1440

        This is also written in the usercontributio n by 'Vextor':
        here: http://nl3.php.net/manual/en/ref.session.php (4 april 2008)
        It seems that the garbage engine can't delete the expired session
        related to the itself. If there is only one session, it won't expire
        even if it has expired the gc_maxlifetime set.

        It will be necessary another client connecting, starting a different
        session, and the garbage collector of this new session will be able to
        clean the other expired sessions.
        Regards,
        Erwin Moller
        >
        C.

        --
        "There are two ways of constructing a software design: One way is to
        make it so simple that there are obviously no deficiencies, and the
        other way is to make it so complicated that there are no obvious
        deficiencies. The first method is far more difficult."
        -- C.A.R. Hoare

        Comment

        Working...