We are having an issue where we have sessions disappearing randomly from Magento 1.10, when we have memcache enabled (on an nginx web server).
It does not seem to matter what we set the cookie expiration time to in Magento, for some reason any random time within an hour the session goes away.
If we turn memcache off, it works fine.
We will eventually need multiple servers connecting to one session based caching solution, so memcache seems like the only option. Also, we are only caching sessions within memcache right now and when I check the memcache stats, we are nowhere near the threshold limit.
Here are the memcache settings in the local.xml
:
<cache>
<type>memcached</type>
<path/>
<servers>
<localhost>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
</localhost>
</servers>
</cache>
<session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files -->
<session_save_path><![CDATA[tcp://localhost:11211?persistent=0&weight;=2&timeout;=10&retry;_interval=10]]></session_save_path>
<session_cache_limiter><![CDATA[private]]></session_cache_limiter>
The hard part of this whole thing is, that it is very hard to reproduce as the session clears sometime within an hour. Sometimes it is within a minute, sometimes 45...
We have had several people here try it in all of the different browsers in multiple virtual server systems (to eliminate conflicts) and they all seem to clear about the same timeish.
Now logic would dictate, that there is a process that is flushing the memcache, but I have not idea how to test for that and if I did, how to tell what it was that cleared it. I looked through the Magento code, but I could not find anything that looked like it was clearing this or removing the session from memcache.
What I did find though is, that the "frontend" cookie stays on the browser after the session is gone and when I check in the memcache slabs, the cookie is gone.
Not all of the key/values are gone from memcache, in this case just some of them. Mine and 2 or 3 others for some reason were completely missing.
Now, what I am asking is not only has anyone ran into this, but does anyone have any additional ideas on what to try?
I have been using the (famous) memcache.php file to monitor the memcache system on the server. Any other ideas/apps I can try?
As clockworkgeek suggested Magento will flush out the sessions when you flush cache storage. If you are using a standalone (non-clustered) server I suggest using tempfs as your session storage and memcache for your cache storage. When it is time to add another server you should run memcache on both. At that time you can use one for session storage and another for cache storage.
Not sure if this will solve you issue:
You need to remove the semicolons to ensure that the settings specified is used.
I tend to see this when the memcached config has been cut'n'pasted from Magento's Community Forum.
Another thing is how much memory have you allocated for your
memcached daemon
?Is the memory being used up due to the traffic on your site. Default
memcached
installation without any alterations sets memory size to 64MB. If the space is used it simply overwrites memory. And you are not in control of wich sessions that is being thrown away.This may or may not be your issue, but it was mine. Putting it here since others may find it useful.
Memcached doesn't take too well to expire times beyond 30 days (2592000 seconds.) Apparently, it interprets numbers larger than that as dates, since the epoch, and expires items immediately.
The session* elements of Magento's local.xml set PHP environment variables. Any relevant PHP environment variables that are not set in the local.xml get set from the php.ini (or other .ini.)
So:
In php.ini, if session.gc_maxlifetime is set above 2592000, you'll get a non-working memcached.
Therefore, change the line in php.ini to the following:
the problem was caused by SSL key not properly setted
Turn off caching and see if the sessions still disappear. If so then content caching is causing sessions to be flushed, use a separate instance of memcache on another port.
Alternatively switch
session_save
todb
and avoid the whole mess in one go.