<p>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.</p>

<pre><code>return array(
    '*' =&gt; array(
    'appId' =&gt; 'myAppId',
),
</code></pre>

CC BY-SA 3.0
2015-05-13T16:26:47.310Z
2015-05-13T16:26:47.310Z
David Rampersad
<p>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.</p>

<p>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.</p>

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

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

<p>Edit: Looks like the autogenerated appId based on filepath must have been the issue.</p>

CC BY-SA 3.0
2015-05-06T22:50:08.120Z
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
CC BY-SA 3.0
2015-05-12T23:10:04.477Z
Would you mind posting what you did to solve it as an official answer in case it can help someone else?
Brad Bell
<templating><users><cache><session><current-user>
sessions being read inconsistently
# sessions being read inconsistently

(Asked by: username_0 on 2015-05-06)

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.

**Tags:** templating, users, cache, session, current-user
> **Comments:**
> **username_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.  
> **username_1**: Would you mind posting what you did to solve it as an official answer in case it can help someone else?  

---

## 1 answers

### Answer by username_0 on 2015-05-13. Score: 1 | Accepted answer

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',
),


---

