1

so I am having a problem with sessions persisting in an application, that is using the memcached php driver, while another existing application is using the memcache driver.

On the server, I see both are installed

I also see in the php config that the Registered save handlers include both memcache, and memcached, however the "session.save_handler" php config value is set to memcache

Would that be the reason that sessions arent working in the application trying to use the memcached driver? Or should that work as well, since memcached, although not the default, is a Registered save handler.

I know the memcached daemon and connection are working since I am successfully saving cache in it through while using the memcached driver.

How do I ever troubleshoot this issue, might it manifest errors or logs anywhere?

1 Answer 1

1

Check your session.gc_maxlifetime setting. Anything bigger than 60*60*24*30 will make memcache expire your session key just after PHP stored it.

Memcache protocol specifies that any number bigger than 60*60*24*30 will be treated as the absolute unix time instead of an offset from the current time:

Some commands involve a client sending some kind of expiration time (relative to an item or to an operation requested by the client) to the server. In all such cases, the actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.

(See https://github.com/memcached/memcached/blob/e31a591210311d0658a90a86f71563fa6d7b095c/doc/protocol.txt#L79)

PHP session handler just uses the session.gc_maxlifetime as the expiration time for session key, without doing any changes on it.

Details at: http://rcmachado.github.io/php/memcache/2014/07/23/php-memcached-gotchas.html (disclosure: I wrote the post).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .