# Keep login email on all site pages

**URL:** <https://forum.wixstudio.com/t/keep-login-email-on-all-site-pages/74468>\
**Category:** Ask the community\
**Tags:** code, wix\
**Created:** [October 24, 2025, 12:39pm UTC](https://forum.wixstudio.com/t/keep-login-email-on-all-site-pages/74468 "2025-10-24T12:39:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isabelle\_YVON](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/isabelle_yvon/32/85148_2.png) [@Isabelle\_YVON](https://forum.wixstudio.com/u/Isabelle_YVON)\
**Post date:** [October 24, 2025, 12:39pm UTC](https://forum.wixstudio.com/t/keep-login-email-on-all-site-pages/74468/1 "2025-10-24T12:39:44Z")

</div>

**I’m having trouble with:**  
Is there a way to keep login information in a global variable so that the pages of the site display in a different way depending on whether the customer is logged in or is just a visitor ?

**Working in**  
Wix Editor

**Site link**

> **[puzzl'éclair | échange](https://novyel.wixsite.com/puzzleclair)**
>
> Puzzl'éclair est un site d'échanges gratuits de puzzles à Lyon.
> Plus de 400 puzzles à échanger gratuitement de particulier à particulier à Lyon. Plateforme collaborative, tout le monde peut proposer ses puzzles !

**What I’m trying to do**  
I would like that logged in visitors have one option more on several pages of my site. The option is hidden, and if the user is a registered user, then the option appears (the option is for instance a button which opens a popup).

**What I’ve tried so far**  
I have tried to create a session variable, to use the masterPage.js, and other ways, but I don’t succeed to keep the information when I navigate from page to page

**Extra context**

Here is an example : the ? button has to be displayed only if a member is connected. I am able to display it one time when I connect myself, but then, when I go to another page and when I come back, it disappears.

 ![Capture d'écran 2025-10-25 101041](https://us1.discourse-cdn.com/wix/original/3X/0/3/03c6312935268e34cd82f8c68757b3a14402300c.jpeg)

Today, as I can’t manage it, I display it all the time…

---

<div class="post-metadata">

**Author:** ![Isabelle\_YVON](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/isabelle_yvon/32/85148_2.png) [@Isabelle\_YVON](https://forum.wixstudio.com/u/Isabelle_YVON)\
**Post date:** [October 27, 2025, 10:19am UTC](https://forum.wixstudio.com/t/keep-login-email-on-all-site-pages/74468/2 "2025-10-27T10:19:25Z")

</div>

Looking for several posts in this forum, I have mixed two methods to success in my project

First, in my home page , the variable userEmail must be declared at the very beginning to be used anywhere in the code

Then

**1** ) I have to insert an authentication async onConnect event to record the loginEmail

**2** ) I have to check the loginEmail whether I authenticate or not, because I can go back to my home page after surfing on other pages.

Here is the results :

> ```javascript
> import { authentication } from 'wix-members';
> import { currentMember } from 'wix-members-frontend';
> 
> let userEmail;
> 
> currentMember //check if a userEmail has been logged in (#2)
> .getMember()
> .then((member) => {
> 
> userEmail = member.loginEmail;
> if (userEmail) {
> $w('#countPuzz').show();
> 
> } else {
> $w('#countPuzz').hide();
> }
> return member;
> })
> 
> .catch((error) => {
> console.error(error);
> })
> 
> //authentication on login event (#1)
> authentication.onLogin(async (member) => {
> $w('#countPuzz').show();
> 
> currentMember // it must be repeated to edit the variable "userEmail"
> .getMember()
> .then((member) => {
> 
> userEmail = member.loginEmail;
> return member;
> 
> })
> 
> .catch((error) => {
> console.error(error);
> })
> 
> });
> 
> ```

And, further, the code

> ```
> **if** ((userEmail == …..
> 
> ```

works in all cases

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/system/32/86885_2.png) [@system](https://forum.wixstudio.com/u/system)\
**Post date:** [November 26, 2025, 10:19am UTC](https://forum.wixstudio.com/t/keep-login-email-on-all-site-pages/74468/3 "2025-11-26T10:19:47Z")

</div>

Closed on November 26, 2025, 10:19am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
