Reputation: 1294
I'm running a website with a nginx server with PHP Fastcgi on a VPS. I tried to configure the php.ini (in /etc/php5/cgi) to have PHP session last longer than 3 days (259200 seconds), but it didn't work and my php sessions don't last more than one hour.
My current session config in the php.ini:
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 259200
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 259200
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 259200
session.use_trans_sid = 0
session.hash_function = 0
What may be the problem here?
Upvotes: 6
Views: 12556
Reputation: 919
To help you debug, you can check the current setting that the PHP cron job is "seeing" by executing:
/usr/lib/php5/maxlifetime
The maxlifetime script searches all your php.ini files for the session.gc_maxlifetime and uses the largest value. The value printed is in minutes.
Upvotes: 4
Reputation: 22408
This sounds a bit like Ubuntu or Debian on the server. If I rememeber correctly there is a cronjob somewhere (installed either by the php5 or the php5-common package) which cleans out your session directory more often.
I'd recommend you configure your sessions to be saved somewhere else (than the default). Adjust session.save_path
and verify to cronjob doesn't empty it.
The cronjob is somewhere like /etc/cron.d/php
- to be certain, run dpkg -L php5
or dpkg -L php5-common
. Assuming you are on Ubuntu (or Debian) this should show you the location of all installed files.
Upvotes: 13