Recording Variables to be available project-wide on all pages

I’d like to set up a variable during login, that will be available to all files afterward.
As an example, I’d like after the Security Login has been validated, to keep the Firstname and Role of the visitor. How is best to do this?
I tried setting up Global $_Session variables and filling them after the login (and Saved the Server Action of course), but they don’t show in the data picker after that.
Maybe Global $_Sessions are only available for subsequent API calls, and there is another way to do this to have FirstName and Role available to page content?
Thank you :slightly_smiling_face:


I haven’t tried this but how about a query in the Globals which selects a single record based on the $identity? Add it after the identity:

Screenshot 2021-02-18 at 13.39.08

Yes, use global steps and add an identify step as well as a single database query filtered by it, returning the user details.
Then they are available for each of your server actions.

1 Like

Hi Fred,
There’s 2 types of session, the server session and browser session.

When you set $_SESSION on the server, this isn’t available in the client-side picker as it only exists on the server.

The best way, I think, to do what you want (although there’s quite a few possible ways) is to return the first name and role as data from a query in your login action. You can then store it in client-side session data using. Just be aware that browser sessions are reset when closing the browser so if you use the ‘remember me’ option, you might have times where the person is logged in but the data in the session storage has been lost. You could store it in local storage, which is permanent or run a server action to refresh it if the user is logged in and it is missing.


@Fred_K the last screenshot on your post is a client side pupop. Server side sessions don’t show up here as @bpj has suggested.

1 Like

Thank you guys. I ended up adding a query for the Firstname and Role in the Globals based on the $identity like >sidestreet mentioned. It seems to do a request every time a page is loaded - as opposed to keeping as variables in the browser. But the extra load isn’t significant so I’ll go with this for now :slight_smile:

You could store it in the browser session or local storage once and then it’s available on the front-end from then on. You just need a page which runs the API script to get the value and store it client-side.

1 Like

You need to add a repeat on your query (presume this is fetching the user), and output the required fields. Then set your sessions inside the repeat binding to the fields you selected to output. Then when your users login the sessions will remain.

1 Like