global variable

I just write to ask experts if i have chosen best solution becasue i need to use variable in many function on pages and dont want to take each time i need

  1. i need to use email to check who is logged in and then filter all pages by email. BEfore i did it by id of user but i realized that when i need to change some datas i can not put someone id. Its logical because i’m not owner. But some pages needs i also put some data but then there is my id.

  2. so i will filter then by email and when insert data add email of user. Is it best way to use like global variable to use users email
    i create email variable —> i make function to return email. → after onready i start function .

  3. then i can use email of user in all function on page without finding each time inside function.

MY QUESTION is is it best way to do it or maybe session or backend . I’m asking becasue i will use user’s email maaaaaaaaaaaaaany times and it should be stable and quick.


let user = wixUsers.currentUser;
let userId =;
let isLoggedIn = user.loggedIn; // true
let email

function findemail(){
if (isLoggedIn) {user.getEmail()
.then((email1) => {
email = email1;

// console.log(email);
return email

$w.onReady( function () {

I am trying to get a solution for a global variable which should be a trivial one to address and there is no response from a WIX expert on this issue. I cannot understand why?

Cliff, what´s your question? Maybe I can help.


Thanks for the response

I have followed the Corvid Reference to ‘setitem’ for a local or session or memory in a variable and then use ‘getitem’ to retrieve it. My code was written as follows

In the Site Code
session.setItem(“strclub”, “Beijing RC”);

In the Page Code
let gstrClub = session.getItem("“strclub”);

Please can you tell me what I am doing wrong ?

Remove the double quote from:

let gstrClub = session.getItem(""strclub"); 

like so:

let gstrClub = session.getItem("strclub"); 

Giri this works. Sorry for my stupid mistake. Many thanks

No problem, but if I am not mistaken, @russian-dima already answered your question in the same manner in your original post.