note 109077 added to function.session-set-cookie-params
| From: | werner dot avenant at gmail dot com | Date: | Tue, 19 Jun 2012 08:58:37 +0000 |
| Subject: | note 109077 added to function.session-set-cookie-params | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188686@lists.php.net to get a copy of this message | ||
Please take note of the garbage collection "feature" on systems like Ubuntu and Debian.
apt-get installs a cron script at /etc/cron.d/php5 that checks the session.gc_maxlifetime variable
and then deletes all old sessions every 9 and 39 minutes.
The problem is: If you set the maxlifetime for a specific virtual host, those settings will be
ignored. Lets say you want your server to store sessions for only 30 minutes, but for one special
website you want all sessions to be 24 hours. If you set the session.gc_maxlifetime in .htaccess,
your apache conf or use ini_set in your code, it won't work and sessions will still be
destroyed after 30 minutes. That's because /usr/lib/php5/maxlifetime (found in that cron file)
will always return the value in your php.ini, not the values you set in .htaccess.
A workaround is to set the maxlifetime to the maximum your sites require, and then configure a
shorter maxlifetime in your .htaccess for those sites that don't need it.
Another solution is to give the php5 file in /etc/cron.d sane values, ie, only let it run at 3am in
the morning, but you'll have to remember to block the replacement of this file it every time
you update php.
----
Server IP: 69.147.83.197
Probable Submitter: 109.74.194.68
----
Manual Page -- http://www.php.net/manual/en/function.session-set-cookie-params.php
Edit -- https://master.php.net/note/edit/109077
Del: integrated -- https://master.php.net/note/delete/109077/integrated
Del: useless -- https://master.php.net/note/delete/109077/useless
Del: bad code -- https://master.php.net/note/delete/109077/bad+code
Del: spam -- https://master.php.net/note/delete/109077/spam
Del: non-english -- https://master.php.net/note/delete/109077/non-english
Del: in docs -- https://master.php.net/note/delete/109077/in+docs
Del: other reasons-- https://master.php.net/note/delete/109077
Reject -- https://master.php.net/note/reject/109077
Search -- https://master.php.net/manage/user-notes.php