Session variables on temporary "Current User"

Hi all

Creating an app where I want to store temporary, session variables.

Let’s say a temporary user writes his name. I want this name to be available across all pages on the app, so the user sees personalised messaging across the app.

According to the Bubble documentation, it seems like a not logged in user does get created as a temporary Current User:

“The temporary user behaves like a signed up user, in the sense that you can modify it, and it will be saved to the application database.” (from here: https://manual.bubble.io/help-guides/working-with-data/authenticating-users#temporary-users)

Thus, I save the name to the Current User. As expected, I cannot see this in the database, but I see it on the front-end under “Current User’s Name”. Great.

This name is available as I move along the pages in the app as long as I don’t open a new tab. When I open a new tab the current user seems to be a new user as “Current User’s Name” is now empty.

I think this is unexpected behaviour. Because a “normal” signed up user will keep being signed up across all tabs in the same session. But since this is not the case for the temp user, then what is written in the docs does not seem to hold true.

Does anyone have any insight on this behaviour?

See example here: https://sharingpublicexamples.bubbleapps.io/version-test?debug_mode=true (set name first, then try the two links)

From a previous post where Emmanuel himself answers:

Given this, I would also expect a temp user’s values to work across tabs.

Indeed, this is the expected behaviour and, having just tested it quickly, I’m seeing this behave as expected.

What device/browser are you seeing this in? And have you got cookies disabled?

Thanks a lot for checking in on this.

Do you also get the behaviour when testing here: https://sharingpublicexamples.bubbleapps.io/version-test

When I do it, I don’t see the name when opening in a new tab: Loom | Free Screen & Video Recording Software

I’m getting the same results as you when clicking on the ‘go to new page (new tab)’ text (i.e. the name is not displaying).

If I use a javascript workflow action instead of a link element to open a new tab the name is showing as expected (so it must be being stored correctly). But with a link element it’s not.

So it seems that somehow the link element (when selecting the open in new tab option) is clearing the cookies (or in some other way clearing the current user and creating a new one) which is not what I would have expected, but it seems that’s the way it is…

Okay, that could be one work-around.

However, this is not really suitable. Because if users then “force” a open in new window (e.g. by holding down “CTRL” when clicking the link) the session variables will be lost.

It does in general seem like Bubble is clearing cookies when opening in a new tab. Because I just tried out the suggested solution by @keith here: How to attach anonymous data to existing user after they log in? - #2 by keith

This works like a charm… until someone opens in a new tab, see example here:

For me, using your link, the cookie value is being read in both cases (in the same tab and the new tab).

But the user’s name is still only showing when opening the link in the same tab.

So I’m not sure what’s going on here - maybe someone else can chime in if anyone knows more…

That’s weird and inconsistent. Hmm… yeah, hopefully someone else can chime in with their results.

What happens if you first do “same tab”, then “new tab” and then “same tab”? I would expect same tab to not work any longer after new tab.

This topic was automatically closed after 70 days. New replies are no longer allowed.