Hi all, I've found the key of all... at least this is what I think ;-)
(And, again, at least, for Debian users)
The thing is I want to have control on what "exactly" a session lasts,
and advice the user some time before to renew the session if he wants.
If you only set gc_maxlifetime with ini_set or even in php.ini the
session management won't work properly... why?
In Debian, garbage collector is called from a cron taks located in
/etc/cron.d/php5
This task is set to be called every 30 minutes, then you can't set
session.gc_maxlifetime less than this time... Because GC won't do its
work till minute 30...
Then, the first thing you should do is set this task to be called in
fewer minutes. ( I set up to */2, i.e. every to minutes)
But this is not enough...
This cron task calls a script located in /usr/lib/php5/ -> maxlifetime.sh:
#!/bin/sh -e
max=1440
for ini in /etc/php5/*/php.ini; do
cur=$(sed -n -e
's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:sp
ace:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
[ -z "$cur" ] && cur=0
[ "$cur" -gt "$max" ] && max=$cur
done
echo $(($max/60))
exit 0
As you see... It opens every php.ini located in /etc/php5 and gets
session.gc_maxlifetime and it keeps the max value of all.
It is compared with max variable and if it's greater it sets $max to
this value... Then, if you set up session.gc_lifetime for example to 600
seconds in all your php.ini's, this script will return 24 minutes (1440
seconds) Because 600 is not greater than 1440. So, you must change the
third line and set max to another value, 600 or less for example.
And this is it... GC will work properly.
I hope it helps to somebody!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php