1

I am trying to setup Craft to use a memcached (yes it is memcached, not memcache) cluster in AWS ElastiCache to handle sessions. I originally went the route of updating my php.ini file in Apache2 to override the PHP session save handler and session save path. That worked at first, but I found that sometimes memcached would seem to return null if a session object was being accessed around the same time. After running into that error a bunch and not being able to resolve it, I decided to try setting up memcached through Craft.

My question is does Craft default to local file storage if it can't connect to my memcached cluster? The reason I think this is happening is because if I use the overridePhpSessionLocation, I can tell that it isn't working because I am getting timed out on my site since we store the timeout in the session. However, when I set overridePhpSessionLocation to 'auto', and then put all the proper information in my memcache.php file, the site seems to work. But if I screw up the hostname in the memcache.php file, the site still works. So what is going on? Is Craft defaulting to local file storage when there is a connection issue or is there something else happening?

1 Answer 1

1

The craft/config/memcache.php file has nothing to do with where PHP sessions are stored. It is for Craft's general purpose data caching.

If you want to save PHP session in memcache, you'll need to set the php.ini save_handler and save_path similar to: https://www.digitalocean.com/community/tutorials/how-to-store-php-sessions-in-memcached-on-a-centos-vps

At this point, I'd suggest not using the overridePhpSessionLocation config setting. Everything it does can be done through php.ini and it's been removed from the upcoming Craft 3 release anyway.

1
  • Brad, thanks for the quick response! I had misunderstood the memcache configuration in Craft. I appreciate the help. I'll go ahead and go back to my first method of updating the php.ini file.
    – Manny
    Sep 5, 2017 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.