2

I know many other folks have posted this question over the years, but unfortunately none of the answers given so far are fixing this for me.

The problem: after logging-in on my staging server (this does not happen locally with MAMP), after a minute the "Your session has ended" modal comes up. Entering my password dismisses the modal for a second then it comes right back.

If I simply reload the page, I am still logged-in, but the modal will come back after another minute. Also, reloading causes my Craft identity cookie to keep its name but change its value.

If I look in /craft/storage/runtime/sessions, I can see that when the modal comes up, a new session file has been created, but is a 0 length file. All the session files have 600 permissions.

What I've tried/checked with no success:

  • session.auto_start = 0 is already set in the php.ini
  • session.save_path shows up correctly as /home/<user>/craft/storage/runtime/sessions/
  • have tried both the overridePhpSessionLocation and requireUserAgentAndIpForSession config variables set to true and false
  • have deleted and recreated the sessions folder manually with 777 permissions
  • have deleted the sessions folder and let it be recreated by Craft (was created with 775 permissions)
  • I am not using any CDN/caching, or running this on Vagrant.

The server is running Apache/2.2.3 (Unix) and PHP 7.1.0.

Is there anything else I can try?

7
  • Are you in a load-balanced web environment by chance?
    – Brad Bell
    Commented Apr 17, 2017 at 21:12
  • Sorry for the delay Brad. I am not, no. Commented Apr 18, 2017 at 20:10
  • Anything session related being logged in craft/storage/runtime/logs when it happens?
    – Brad Bell
    Commented Apr 18, 2017 at 21:10
  • Nope, nothing gets logged at all when the session times out in fact. Commented Apr 19, 2017 at 13:04
  • Hrm... I assume you've been through craftcms.stackexchange.com/questions/952/…
    – Brad Bell
    Commented Apr 19, 2017 at 18:05

2 Answers 2

3

Thanks to Brad's help, we discovered that the server was misconfigured with an incorrect value for session.cookie_domain. Fixing that resolved the issue in this case.

2

Try all of the above suggestions first, then...

If you've added the configuration of 'defaultCookieDomain' to /craft/config/general.php as I did, you may see this error. I'm using MAMP which has no value set for session.cookie_domain in php.ini. I'm assuming that the conflict between my config setting in Craft and the setting in php.ini was the cause of this issue? To resolve the issue, I just removed the defaultCookieDomain in Craft general.php and the problem is resolved.

I'm not sure that it's even necessary to set defaultCookieDomain considering what the Craft documentation says about this config: "The default domain name Craft will use when sending cookies to the browser. If it is left blank, Craft will leave it up to the browser to decide – which will be whatever the current request’s domain name is."

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.