469,330 Members | 1,329 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

session.gc_maxlifetime

Hi all

I'm trying to set my sessions to be deleted after 60 seconds of
inactivity (for testing), however they seem to be deleted after 60
seconds regardless of activity.

I have the following in my php.ini file:

session.gc_maxlifetime = 60
session.gc_probability = 100

I have a login check script on every page that prints the current time
to the session, however my session is *always* deleted after 60
seconds, not after 60 inactive seconds.

It is my understanding that session.gc_maxlifetime is the number of
seconds an inactive session is allowed to live...is this correct?

If so why does my session get deleted after 60 seconds even though it's
active?

Thanks for any help!

JA

Jul 17 '05 #1
7 30519
ja***********@gmail.com wrote:
Hi all

I'm trying to set my sessions to be deleted after 60 seconds of
inactivity (for testing), however they seem to be deleted after 60
seconds regardless of activity.

I have the following in my php.ini file:

session.gc_maxlifetime = 60
session.gc_probability = 100

I have a login check script on every page that prints the current time
to the session, however my session is *always* deleted after 60
seconds, not after 60 inactive seconds.

It is my understanding that session.gc_maxlifetime is the number of
seconds an inactive session is allowed to live...is this correct?


Nope! From my PHP 5 php.ini:
-----
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
-----
It appears to have nothing to do with (in)activity.

NM

--
convert UPPERCASE NUMBER to a numeral to reply
Jul 17 '05 #2
Thanks. I thought this was the case but I've seen different
explanations online. That being said, is there a way in php.ini to
have a session timeout after "x" seconds of *in*-activity?

JA

Jul 17 '05 #3
ja***********@gmail.com wrote:
Thanks. I thought this was the case but I've seen different
explanations online. That being said, is there a way in php.ini to
have a session timeout after "x" seconds of *in*-activity?

JA


nope.

best thing you could do would be to look at each request for a given
session, and see when the last request was (you would have to save a 'last
request time' for each session). if it was more than sixty seconds prior,
you could manually nuke the session yourself.

mark.
--
I am not an ANGRY man. Remove the rage from my email to reply.
Jul 17 '05 #4
<ja***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Thanks. I thought this was the case but I've seen different
explanations online. That being said, is there a way in php.ini to
have a session timeout after "x" seconds of *in*-activity?

JA


Dude, these guys are totally pulling your legs. Session file garbage
collection is based on the last-modified-time of the session file. The
last-modified-time is updated whenever the session is accessed (regardless
of whether the session variables have changed or not). The catch is that the
session cannot be completely empty.
Jul 17 '05 #5
If that's true (and I hope it is) why does my session get deleted after
60 seconds even though the last-modified-time changes?

JA

Jul 17 '05 #6
ja***********@gmail.com wrote:
If that's true (and I hope it is) why does my session get deleted after 60 seconds even though the last-modified-time changes?


There *was* some issues under Windows (FAT), but that was sorted out
<http://in2.php.net/session#ini.session.gc-maxlifetime> Perhaps you
should be more specific about your OS, PHP versions, etc?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #7
Source codes don't lie:

// mod_files.c, line 219

if (VCWD_STAT(buf, &sbuf) == 0 &&
(now - sbuf.st_mtime) > maxlifetime) {
VCWD_UNLINK(buf);
nrdels++;
}

Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Daniel Bengs | last post: by
2 posts views Thread by Damien | last post: by
1 post views Thread by mudge | last post: by
reply views Thread by joseph conrad | last post: by
1 post views Thread by seigan | last post: by
1 post views Thread by Rogier | last post: by
6 posts views Thread by laredotornado | last post: by
3 posts views Thread by jodleren | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.