0

I'm running a PHP application on Heroku and handling sessions using Memcachier add-on.

What Works: - Memcachier successfully keeps users logged in through new deployments to Heroku.

What Doesn't Work - Users will get logged out randomly throughout their time in the web application.

How do I get the user sessions to stay logged in (until the user logs out - or some other automatic login policy we put in place)?

drummer392
  • 473
  • 2
  • 8
  • 35

1 Answers1

0

Memcache is not recommended for storing sessions as it is a cache and not a persistant cache. What this means is that any key/value pair can get pushed out by new pairs if the cache is full. To get session persistance either switch to a different memcache server (with persistance) or store you sessions differently (eg: in a database)

Steve
  • 1,769
  • 2
  • 22
  • 33
  • According to documentation on Heroku, they recommend Memcachier for storing persistent sessions. What I've done so far is upgrade my Memcachier to more space to see if that fixes the problem. – drummer392 Jul 06 '18 at 01:41
  • Interesting that they recommend that. Normally it not recommended to use memcache for session info as you can have the type of problem that you are currently experiencing, ie: a session can get evicted from the cache at any moment. One solution is to ask for more RAM from mamcachier. However, the problem can still re-occur as you use the extra RAM to cache other stuff. Also, I would examine the memcache statistics, specifically the eviction stats. – Steve Jul 06 '18 at 07:13