<p>The <code>craft/config/memcache.php</code> file has nothing to do with where PHP sessions are stored.  It is for Craft's <a href="https://craftcms.stackexchange.com/questions/13382/what-are-the-cache-options-available-to-a-craft-installation/13383#13383">general purpose data caching</a>.</p>

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

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

CC BY-SA 3.0
2017-09-05T19:59:03.580Z
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
CC BY-SA 3.0
2017-09-05T18:34:52.003Z
2017-09-05T18:34:52.003Z
Brad Bell
<p>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.</p>

<p><strong>My question is does Craft default to local file storage if it can't connect to my memcached cluster?</strong> 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?</p>

<php><session><apache><aws>
Craft cacheMethod setting is being overridden
# Craft cacheMethod setting is being overridden

(Asked by: username_0 on 2017-09-05)

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?

**Tags:** php, session, apache, aws


---

## 1 answers

### Answer by username_1 on 2017-09-05. Score: 1 | Accepted answer

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](https://craftcms.stackexchange.com/questions/13382/what-are-the-cache-options-available-to-a-craft-installation/13383#13383).

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.

> **Comments:**
> **username_0**: 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.  

---

