Membership Login & logout issue

We’re encountering an issue while implementing the login and logout functionality on our HubSpot website. We’ve utilized the default membership registration and login features, allowing users to create their accounts. However, it seems there’s an issue with data caching. Even when a user is not logged in, the logout button continues to appear.

Here is the link to our website:

And below is the registration link:
[Link here]

Hey @BPatel1,

for your own (business) security - I’m strongly recommend to delete the registration link from the community.

In terms of errors - have modified the template, any asset from the theme or the module?

best,

Anton

We’ve added below code in template (header.html) file.
{% if request_contact.is_logged_in %}
<div class=“auth_nav”>
<a href=“/_hcms/mem/logout”>LOG OUT {{ request_contact.first_name }}</a>
</div>
{% else %}
<div class=“auth_nav”>
<a href=“/_hcms/mem/register”>JOIN NOW</a>
<a href=“/_hcms/mem/login”>LOG IN</a>
</div>
{% endif %}
But looks like it’s caching the request and login & logout feature not working properly.

Hey @BPatel1,

thank you for the code.
I think I get the issue now. I assume it’s not a caching thing but more how HubSpot handles this information.

Login information is stored in something like a special CRM property. And as far as I know you can access this information only on a membership/password protected page - simply because its personal data and HubSpot protects it.
You can easily test this if you put this code on a page that is accessible after the actual login page.

Example:
You got this code on every page. Once you log in you’ll be redirected to a different page - this page should then show you “Log out” but if you open a non-password-protected page(what memberships basically are) then you should still see Join now and Log in - even if you’re logged in in a different tab.

hope this helps

best,

Anton

Thanks for your quick response. Looks like it’s solved automatically. It’s mostly due to cache only.