Troubleshooting · Developer docs

Troubleshooting

Grouped by symptom, never by module, because the person with the problem does not know which module has it. One hundred questions across ten pages, each answered with the causes in the order they usually turn out to be true.

A member can log in but sees the logged-out header

The sign-in worked, because /my-account opens, but the header still says "Sign in". In order:

  1. The page came from the cache. The page cache is read before the platform knows who is asking, and its key ignores cookies. Once an anonymous visitor has requested a URL, everyone gets that copy, members included. Check the response headers: X-Cache-Status: hit means a cached copy. Load the personal part of the header as a fragment, or prevent caching on pages whose output depends on the visitor (member pages and the page cache).
  2. A different hostname. The sign-in cookie, token, is set for the exact hostname. A member signed in on example.com is signed out on www.example.com. Redirect every hostname to one.
  3. The template tests the wrong thing. isFrontendUser() is also true for a signed-out visitor, because the default type is frontend. Test isLoggedIn().
  4. The fragment is cached too. A script that fetches the header's personal part must fetch it from a page that is never cached for a member, such as one under /my-account.
Template code
{if $_currentUser->isLoggedIn()}
  <a href="{$_url->getPath('account')}">My account</a>
{else}
  <a href="{$_url->getPath('login')}">Sign in</a>
{/if}
{% if _currentUser.isLoggedIn() %}
  <a href="{{ _url.getPath('account') }}">My account</a>
{% else %}
  <a href="{{ _url.getPath('login') }}">Sign in</a>
{% endif %}

That test is correct, but it only helps on a page that is not served from the cache.

More in Members and authentication

  1. A member is logged out at random
  2. The password reset email never arrives
  3. A frontend user can reach an admin URL
  4. A custom my-account page is not found
  5. Sign-in with an external provider returns to an error page

Was this page helpful?

Your answer goes to the docs team.