My session never expires no mater what value i put here:

session.gc_maxlifetime = 1440

Do i need to change these values to do that? Notice that the cookie_lifetime is set to 0. If this is th ecase, kindly provide some explanation as to why.

; Whether to use cookies.
session.use_cookies = 1
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

    Set session.cookie_lifetime to a non-zero value (in seconds). Session.gc_maxlifetime is kind of a "fuzzy" thing, in that data is not destroyed until a session_start() is executed by a script that saves session data in that same directory, and is also affected by session.gc_probability and session.gc_divisor.

      Thanks, I changed the the value of session.cookie_lifetime and it did the trick. But I still don't understand. The php manual suggests that Session.gc_maxlifetime is what governs the session life, so why do I need to change session.cookie_lifetime?

        the gc (garbage collection) stuff deletes session data when all the following are true:

        1. The time since the last access of that session data was more than session.gc_maxlifetime seconds ago, AND

        2. Any script that uses the same session data directory does a sessions_start(), AND

        3. A random number between 0 and 1 is less than the value of session.gc_probability / session.gc_divisor.

        Additionally, I'm not sure what the sequence of events are, but my guess is that if the session_start() is from a request with a still-valid session cookie, then the session data for that session ID is accessed before the garbage collection is executed (if the random number versus the probability says to), so that particular session's data would not be seen as "garbage".

        Ultimately, the garbage collection is a background maintenance activity designed to keep disk drives from filling up with old session data -- it is not really intended as a means to time out sessions, that being best controlled by the cookie setting.

          Write a Reply...