How to prevent Memberstack from logging users out when opening a PWA from Home Screen?
Quick one - when saving my PWA to the Home Screen, when clicking back on the icon initially after doing so, Memberstack logs the user out (I guess maybe because it’s a new browsing session?). Is there any way to keep the user logged in? Perhaps there’s an ‘active session’ cookie I can leverage or something similar?
So leveraging local storage could be the way? Interesting - if so, any ideas how I would pass that onto the standalone mode and keep the user logged in?
Apparently I can capture the auth token on successful login in the browser (or when the user creates an account), then store it in Xano.
Then, when the user launches the standalone mode for the first time, I can call Xano, get the auth token, and then re authenticate the user via Memberstack? Thus, removing 1 step for the user (not having to log back in again during this flow).
Comments
1 comment
Oooo nice!
Did you try this yet?
The Solution
---------------------
Enable cookie-based authentication by adding the attribute mentioned in that documentation:
If using Webflow Package:
html
If using DOM Package:
javascript
const memberstackInit = memberstackDom.init({publicKey,
appId,
useCookies: true
})
Why This Works
----------------------
Cookies (unlike localStorage) are shared across browsing contexts on the same domain, including:
This should keep your users logged in when opening the PWA from the home screen icon.
Note: Make sure your cookies are set with appropriate flags (Secure, HttpOnly if possible, and appropriate SameSite settings) for security and cross-context compatibility.
Try this and let me know if it resolves the issue!
Please sign in to leave a comment.