# Session variables on temporary "Current User"

**URL:** <https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261>\
**Category:** Need help\
**Created:** [March 9, 2022, 10:25am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261 "2022-03-09T10:25:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![maja-overgaard](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maja-overgaard/32/114696_2.png) [@maja-overgaard](https://forum.bubble.io/u/maja-overgaard)\
**Post date:** [March 9, 2022, 10:25am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/1 "2022-03-09T10:25:21Z")

</div>

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](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](https://sharingpublicexamples.bubbleapps.io/version-test?debug_mode=true) (set name first, then try the two links)

---

<div class="post-metadata">

**Author:** ![maja-overgaard](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maja-overgaard/32/114696_2.png) [@maja-overgaard](https://forum.bubble.io/u/maja-overgaard)\
**Post date:** [March 9, 2022, 10:29am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/2 "2022-03-09T10:29:29Z")

</div>

From a previous post where Emmanuel himself answers:

> [@Session variables](http://forum.bubble.io/t/session-variables/6699/12):
>
> Hello, As soon as a Bubble web app is opened, a user is created in the database, and it’s using the cookie to represent him/her, until he signs up. So if you modify the current user that isn’t logged in, it’ll modify that object in the db (the 3 days are revolving)

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

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 9, 2022, 11:38am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/3 "2022-03-09T11:38:12Z")

</div>

> [@maja-overgaard](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![maja-overgaard](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maja-overgaard/32/114696_2.png) [@maja-overgaard](https://forum.bubble.io/u/maja-overgaard)\
**Post date:** [March 9, 2022, 11:48am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/4 "2022-03-09T11:48:19Z")

</div>

Thanks a lot for checking in on this.

Do you also get the behaviour when testing here: [https://sharingpublicexamples.bubbleapps.io/version-test](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](https://www.loom.com/share/4b0a60101e1748c783a7a2fc7398a390)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 9, 2022, 12:49pm UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/5 "2022-03-09T12:49:56Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![maja-overgaard](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maja-overgaard/32/114696_2.png) [@maja-overgaard](https://forum.bubble.io/u/maja-overgaard)\
**Post date:** [March 9, 2022, 1:04pm UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/6 "2022-03-09T13:04:38Z")

</div>

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](http://forum.bubble.io/t/how-to-attach-anonymous-data-to-existing-user-after-they-log-in/32269/2)

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

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [March 9, 2022, 1:25pm UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/7 "2022-03-09T13:25:09Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![maja-overgaard](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/maja-overgaard/32/114696_2.png) [@maja-overgaard](https://forum.bubble.io/u/maja-overgaard)\
**Post date:** [March 9, 2022, 1:32pm UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/8 "2022-03-09T13:32:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [May 18, 2022, 10:25am UTC](https://forum.bubble.io/t/session-variables-on-temporary-current-user/195261/9 "2022-05-18T10:25:24Z")

</div>

Closed on May 18, 2022, 10:25am UTC

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