How can I set a session variable for a logged in user?
Specifically, I have a user that can belong to several accounts. They need to be able to select which account they want to interact as when they are using the front end, and then change that as they are using it.
Hey @kevinwasie . I am not sure if I understand you, because I know you are very proficient with WeWeb and my answer is pretty straightforward. I have something like this, where one user might belong to multiple “hubs”, and can switch between them by selecting a different hub from a dropdown menu in the nav bar. The “Current Hub” is a variable that changes upon selection of a new hub. All relevant data are then filtered by the “Current Hub” variable, so they are only seeing the data for that hub.
If a user does not explicitly log out, won’t the local variable will still be present (as it’s in local storage, which is saved across sessions)?
I am trying to make it so that the variable carries over from page to page, and stays as it is until they logout, or they change it.
I’m still new to WeWeb, so forgive the naivety here—aren’t regular variables session variables that persist across pages? Ie, they’re stored in sessionStorage)? Or are the regular WeWeb variables only page-level variables?
I think this topic was created before we moved to Single Page Application. Now that we are navigating inside the SPA, rather than reload the page each time, the variable are persisted between page (but will be loose on refresh).
Store in localstorage is used if you want to persist the information between session (page refresh for example).
Hi @aurelie, I wanted to bring up what you said here following the release of the new updates (which I’m absolutely PUMPED about).
As I’ve understood…
When navigating inside the SPA, variables persists (as you mention).
Variables only reset when refreshing the page.
With both of those things mentioned, how does the new “save variable when navigating between pages” feature work? How does it differ between a regular variable if regular variables already persist between pages?