By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

session.gc_maxlifetime

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
<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

P: n/a
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

P: n/a
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

P: n/a
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.