Gajus
Gajus

Reputation: 73788

PHP memcached session expires out of the blue

session.save_handler = memcached
session.save_path = "127.0.0.1:11211"
session.gc_maxlifetime = 86400

The rest it standard. I expect the session to be kept alive for at least 86400 seconds since the last time user visited the page, ie If I started a session and visited page 5 minutes later, the session should expire only after another 86400 seconds.

However, now session expires after roughly an hour. I've attached screenshot for the phpMemcachedAdmin.

enter image description here

Upvotes: 2

Views: 11203

Answers (2)

Yuki Matsukura
Yuki Matsukura

Reputation: 456

; Document expires after n minutes.
; http://php.net/session.cache-expire
session.cache_expire = 1440

This setting might be affected if you use memcached session handler.

Upvotes: -1

Tchoupi
Tchoupi

Reputation: 14681

There are other parameters that might apply:

Your session cookie might expire early. Calling session_set_cookie_params(86400) will ensure that your session cookie exists as long as your actual session.

Also, gc_maxlifetime set a maximum for your session lifetime. Don't forget that the garbage collection is triggered by a probability: http://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability:

session.gc_divisor coupled with session.gc_probability defines the probability that the gc (garbage collection) process is started on every session initialization. The probability is calculated by using gc_probability/gc_divisor, e.g. 1/100 means there is a 1% chance that the GC process starts on each request. session.gc_divisor defaults to 100.

You might try to check/change these settings too.

Upvotes: 9

Related Questions