# Need help with using session.setItem and session.getItem

**URL:** <https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [March 5, 2023, 6:11am UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864 "2023-03-05T06:11:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 5, 2023, 6:11am UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/1 "2023-03-05T06:11:14Z")

</div>

This may be trivial, but I have spent 2 days trying various options to pass a parameter from one page to another. Of course, it hasn’t worked or I wouldn’t be here.

Help would be greatly appreciated!

Below is my code and log results:

Page 1

* * *

import { session } **from** ‘wix-storage’ ;

$w . onReady ( **function** () {

$w ( ‘#button1’ ). onClick (( event ) =\> {  
session . setItem ( “stage” , “1” );  
console . log ( 'Stage selected is ’ + session . getItem ( “stage” ) );  
});

$w ( ‘#button2’ ). onClick (( event ) =\> {  
session . setItem ( “stage” , “2” );  
console . log ( 'Stage selected is ’ + session . getItem ( “stage” ) );  
});

$w ( ‘#button3’ ). onClick (( event ) =\> {  
session . setItem ( “stage” , “3” );  
console . log ( 'Stage selected is ’ + session . getItem ( “stage” ) );  
});

$w ( ‘#button4’ ). onClick (( event ) =\> {  
session . setItem ( “stage” , “4” );  
console . log ( 'Stage selected is ’ + session . getItem ( “stage” ) );  
});

$w ( ‘#button5’ ). onClick (( event ) =\> {  
session . setItem ( “stage” , “5” );  
console . log ( 'Stage selected is ’ + session . getItem ( “stage” ) );  
});

});

Page 2

* * *

import { session } **from** ‘wix-storage’ ;

$w . onReady ( **function** () {  
session . getItem ( “stage” );  
console . log ( 'Stage received is ’ + session . getItem ( “stage” ) );

});

Logs

* * *

Running the code for the Stage Selection for Stage Variables page. To debug this code in your browser’s dev tools, open zqgnc.js.

**Stage selected is 1**

Stage Selection for Stage Variables  
Line 13

Running the code for the Stage Variables page. To debug this code in your browser’s dev tools, open hxphl.js.

**Stage received is 5**

Stage Variables  
Line 11

Running the code for the Stage Selection for Stage Variables page. To debug this code in your browser’s dev tools, open zqgnc.js.

**Stage selected is 2**

Stage Selection for Stage Variables  
Line 18

Running the code for the Stage Variables page. To debug this code in your browser’s dev tools, open hxphl.js.

**Stage received is 1**

Stage Variables  
Line 11

Running the code for the Stage Selection for Stage Variables page. To debug this code in your browser’s dev tools, open zqgnc.js.

**Stage selected is 3**

Stage Selection for Stage Variables  
Line 23

Running the code for the Stage Variables page. To debug this code in your browser’s dev tools, open hxphl.js.

**Stage received is 2**

Stage Variables  
Line 11

Running the code for the Stage Selection for Stage Variables page. To debug this code in your browser’s dev tools, open zqgnc.js.

**Stage selected is 4**

Stage Selection for Stage Variables  
Line 28

Running the code for the Stage Variables page. To debug this code in your browser’s dev tools, open hxphl.js.

**Stage received is 3**

Stage Variables  
Line 11

Running the code for the Stage Selection for Stage Variables page. To debug this code in your browser’s dev tools, open zqgnc.js.

**Stage selected is 5**

Stage Selection for Stage Variables  
Line 33

Running the code for the Stage Variables page. To debug this code in your browser’s dev tools, open hxphl.js.

**Stage received is 4**

---

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 6, 2023, 5:24pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/2 "2023-03-06T17:24:54Z")

</div>

Help would be greatly appreciated. I see views going up, but no help yet.

Thanks!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 6, 2023, 5:58pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/3 "2023-03-06T17:58:36Z")

</div>

Maybe because you are an unknowm member?  
There are a lot of UKNOWM-MEMBER here just hunting for some free-codes, to avoid payed coders.

Maybe you first become a → KNOWN-MEMBER?

---

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 6, 2023, 9:52pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/4 "2023-03-06T21:52:12Z")

</div>

I am a member!!! Now, would you please help me.

---

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 6, 2023, 9:52pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/5 "2023-03-06T21:52:42Z")

</div>

I am a member! Now would you please help me.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 6, 2023, 10:16pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/6 "2023-03-06T22:16:49Z")

</div>

You are talking about that something do not work.  
What exactly do not work ?

---

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 6, 2023, 11:40pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/7 "2023-03-06T23:40:11Z")

</div>

Please review information supplied. I am trying to pass a parameter from page to page 2 using session.setiTem and session.getItem. As you can see from the console logs provided, the selected value does not equal the received value.

Pretty simple, just not working.

Thanks for your time and support!

---

<div class="post-metadata">

**Author:** ![amandam](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/amandam/32/79539_2.png) [@amandam](https://forum.wixstudio.com/u/amandam)\
**Post date:** [March 7, 2023, 6:55pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/8 "2023-03-07T18:55:32Z")

</div>

The unknown member showing is a forum issue. If you see blank avatars with “unknown member”, you may have to refresh. I have made the forum team aware that this happens sometimes.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 7, 2023, 7:11pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/9 "2023-03-07T19:11:48Z")

</div>

Regarding your code, everything looks just well.  
Testing your code —\> also works like a charm!

Just a simple testing page…

[https://russian-dima.wixsite.com/my-site-4/blank-6](https://russian-dima.wixsite.com/my-site-4/blank-6)

**Page-1 (sendind…)**

```javascript
import wixlocation from 'wix-location'
import {session} from 'wix-storage';

$w.onReady(()=> {   
    $w('#button1').onClick((event) => {    
        session.setItem("stage", "1");
        console.log('Stage selected is ' + session.getItem("stage") );
        wixlocation.to("https://russian-dima.wixsite.com/my-site-4/reciever-site");
    });   

    $w('#button2').onClick((event) => {
        session.setItem("stage", "2");
        console.log('Stage selected is ' + session.getItem("stage") );
        wixlocation.to("https://russian-dima.wixsite.com/my-site-4/reciever-site");
    });   

    $w('#button3').onClick((event) => {
        session.setItem("stage", "3");
        console.log('Stage selected is ' + session.getItem("stage") );
        wixlocation.to("https://russian-dima.wixsite.com/my-site-4/reciever-site");
    });   

    $w('#button4').onClick((event) => {
        session.setItem("stage", "4");
        console.log('Stage selected is ' + session.getItem("stage") );
        wixlocation.to("https://russian-dima.wixsite.com/my-site-4/reciever-site");
    }); 

    $w('#button5').onClick((event) => {
        session.setItem("stage", "5");
        console.log('Stage selected is ' + session.getItem("stage") );
        wixlocation.to("https://russian-dima.wixsite.com/my-site-4/reciever-site");
    });  
});

```

Page-2…(receiving):

```javascript
import {session} from 'wix-storage';

$w.onReady(()=> {    
    session.getItem("stage");
    console.log('Stage received is ' + session.getItem("stage"));
});

```

Do the test and take a look at console.

---

<div class="post-metadata">

**Author:** ![dwmilli](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dwmilli/32/36680_2.png) [@dwmilli](https://forum.wixstudio.com/u/dwmilli)\
**Post date:** [March 8, 2023, 4:12pm UTC](https://forum.wixstudio.com/t/need-help-with-using-session-setitem-and-session-getitem/3864/10 "2023-03-08T16:12:28Z")

</div>

If the code is good, why did my log show stage selected and stage received were different almost every run? The best I can tell is that it was some kind of a timing issue using my stage site. Once I out a timeOut in on my receiving page, it began working for me. I never thought storing data using “session” would be impacted by timing, but it was. Does that make sense to you?

Thanks for your time and support! I appreciated the help.

Sincerely,  
Doug Milligan
