Skip to content

Conversation

@Jade-GG
Copy link
Collaborator

@Jade-GG Jade-GG commented Dec 31, 2025

ref: GT-2426

This issue came about whenever a logged in customer opened a new tab, or even just if already logged in previously came back to the shop. sessionStorage gets cleared, which causes the stored email to also no longer exist.

There are a few alternative approaches to fixing this that I explored:

  • Using localStorage for the user data instead. I chose not to use this solution because it didn't really address the underlying bug. Furthermore this may cause more issues with session lifetimes being exceeded.
  • Specifically using localStorage only to store the user's email, fixing this specific check. To me, this seems like a good way to create new weird bugs with data coming from multiple different sources.

At the end, I opted for the solution you see in this PR. As we really only need to call the logged-in event (and link a guest cart to a user) when you actually log in yourself, there is no need to also go through this every time the customer is refreshed. The loginByToken function is the only code path where you actually need to do this (the login-as-customer code also uses this function to log in).

For safety, I changed the code so that it refreshes the cart whenever this bug would happen before.

@royduin
Copy link
Member

royduin commented Jan 6, 2026

Didn't we fix this recently with another PR @indykoning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants