Connecting Tech Pros Worldwide Forums | Help | Site Map

session.gc_maxlifetime

jarret.austin@gmail.com
Guest
 
Posts: n/a
#1: Jul 17 '05
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


News Me
Guest
 
Posts: n/a
#2: Jul 17 '05

re: session.gc_maxlifetime


jarret.austin@gmail.com wrote:[color=blue]
> 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?[/color]

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
jarret.austin@gmail.com
Guest
 
Posts: n/a
#3: Jul 17 '05

re: session.gc_maxlifetime


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

Mark
Guest
 
Posts: n/a
#4: Jul 17 '05

re: session.gc_maxlifetime


jarret.austin@gmail.com wrote:
[color=blue]
> 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[/color]

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.
Chung Leong
Guest
 
Posts: n/a
#5: Jul 17 '05

re: session.gc_maxlifetime


<jarret.austin@gmail.com> wrote in message
news:1108084828.484105.220670@f14g2000cwb.googlegr oups.com...[color=blue]
> 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
>[/color]

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.


jarret.austin@gmail.com
Guest
 
Posts: n/a
#6: Jul 17 '05

re: session.gc_maxlifetime


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

R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
#7: Jul 17 '05

re: session.gc_maxlifetime


jarret.austin@gmail.com wrote:[color=blue]
> If that's true (and I hope it is) why does my session get deleted[/color]
after[color=blue]
> 60 seconds even though the last-modified-time changes?[/color]

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/

chernyshevsky@hotmail.com
Guest
 
Posts: n/a
#8: Jul 17 '05

re: session.gc_maxlifetime


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++;
}

Closed Thread