It seems that after x amount of time (somewhere between 30-60 mins?) of inactivity on a page the session is being destroyed/cleared/etc.

I will sit on a page with an active session for an hour and make 0 calls to the PHP. The next time I make a call to my PHP the session is completely gone. I have 0 variables in my session. I'm logging in the beforeAction and the session is just an empty array.

I thought it was my custom code that was clearing the session accidentally but before my code even executes the session is gone which leads me to believe it has something to do with Craft bootstrapping up to receive the PHP request.

2 Answers 2


You're likely running into Craft's userSessionDuration config setting. It defaults to one hour and will automatically log you out (thereby destroying your session) after reaching that period of inactivity.

  • What's weird is I'm not even logged into Craft. Does a a userSession exist even if you haven't authenticated? I tried setting userSessionDuration to PT8H but that didn't resolve the issue (I also am not sure if the T is needed for an hours interval which could've been the case).
    – Exziled
    Commented Sep 6, 2017 at 19:21
  • Oh... thought you were referring to an authenticated Craft session. If it's just PHP session, there are php.ini settings for that: stackoverflow.com/questions/9904105/…
    – Brad Bell
    Commented Sep 6, 2017 at 21:22

If you're running on Ubuntu, this will be relevant as well: The Case of the Missing PHP Session

Your Answer

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

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