1

I've got a navigation bar that displays different links for logged in users using {% if currentUser %}. However, when clicking through links, sometimes it won't pick up that someone is logged in.

The same issue crops up occasionally with "denied permissions" error pages. Again, reloading the page will pick up the user session and display the template normally.

It's inconsistent which pages (and servers) it happens on. I'm not using any {% cache %} tags in the twig templates either.

Is there a cp setting or config/general.php option I'm missing?

Edit: Looks like the autogenerated appId based on filepath must have been the issue.

  • 1
    Do you get the same behavior in the CP? Maybe you're in a load-balanced environment and you need to enable stick sessions at the router level? Or maybe PHP's session files aren't being saved properly. Make sure that folder exists and that it's writable by PHP. – Brad Bell May 6 '15 at 22:50
  • 2
    Would you mind posting what you did to solve it as an official answer in case it can help someone else? – Brad Bell May 12 '15 at 23:10
1

The site was on amazon AWS (without load balancing), so I set an appId in the config/general.php file to keep the session "sticky", even if the filepaths were "inconsistent" on a single server instance. The autogenerated appId based on filepath must have been interacting weird with Amazon's cloud setup.

return array(
    '*' => array(
    'appId' => 'myAppId',
),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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