Session.setItem / Session.getItem

Hi!,

I am trying to set flags between to pages, the first regular, the second dynamic. I think I’ve followed steps from docs https://support.wix.com/en/article/corvid-tutorial-creating-a-one-time-popup , and https://www.wix.com/corvid/reference/wix-storage/storage/setitem / getItem…

However, in the first page, for the flag set up in the code pasted below (//COMMENT1), console.log is always showing me the page’s name. Actually I changed the name just to be sure.

Some help would be great

import wixLocation from 'wix-location';
import {session} from 'wix-storage';

$w.onReady(() => {

    session.setItem("general", "yes"); //COMMENT1
    console.log ("origen value")

            $w("#repeater3").onItemReady(($w, dataItem, index) => {
 let linkToDynamicPage = dataItem["link-clubbitcomercios-title"];
        $w('#imageX31').onClick(() => {
            wixLocation.to(linkToDynamicPage);
        });
    });
});

Could you solve your problem already??

Thanks for answering. No I couldn’t

Finally, I decided to code using the pages’s name,. But in case I want to set two session flags from the same page, I would be stuck

It’s probably an obvious error in my coding, but I just don’t get it

Do you have any ideas ?

I think i do not understand your issue properly.

Can you explain a little bit more what you are trying to do (without using the word flag :grin:) I do not understand what you mean, when you say that you want to set flags between 2-pages.

Please describe in other words. My english is not perfect as you can see :grin:.

I just see you are trying to work with the Wix-Storage {session}.

So i assume, you want let communicate two pages, right?

Describe what should happen, step by step.

So, I’m trying to partially replicate the use of the session.setItem / session.getItem, that is extensively explained in the wix article mentioned ( https://support.wix.com/en/article/corvid-tutorial-creating-a-one-time-popup ). The difference is that I am not using wix-window, as I am not opening anything with code

There are other ways to do it, but I just tried to replicate the use of session.setItem/session.getItem from the article and I couldn’t

That’s about everything, but I don’t get it. It’s not an issue, I’m not stuck, but I would like to know how those tools should be used

Thanks anyway,

Ok, i am still not completely understanding what you are searching for, but if you want to undestand how to use the Wix-Storage…

https://www.wix.com/corvid/reference/wix-storage/introduction

Then i can give you an little example…here…

https://russian-dima.wixsite.com/meinewebsite/lightbox

This example shows you how to create the data-transfer from your page to lightbox. It’s a similar situation, as if you would transfer data from one page to another without loosing the data (after refreshing your site for example).

First of all, thanks for the time your are taking on answering
Second, appologies if I write some misconceived code, as I have a few weeks of coding, so I am at the begining of my learning curve

In your example of session.setItem usage, I see you use an onclick event and as key for the session.setItem you use an element on the page $w(“#inputMain”).value

I would like to use any key, as I understand wix uses in the refered article. They made up a key ( firstTimePopupShown in their example) and give it a value. I am trying to replicate what they do, as it is very simple (saddly not to me though)

Code extracted from wix article: https://support.wix.com/en/article/corvid-tutorial-creating-a-one-time-popup

$w.onReady( function () {
// flag is not found
if (!session.getItem( “firstTimePopupShown” )) {
// open popup
wixWindow.openLightbox( “Announcement” );
// set flag for future visits
session.setItem( “firstTimePopupShown” , “yes” ); } } );

Thanks again

https://russian-dima.wixsite.com/meinewebsite/onetime-popup

import {session} from 'wix-storage';
import wixWindow from 'wix-window';

$w.onReady(function () {
//  $w('#button1').onClick(()=>{
        console.log(session.getItem("PopupState"))
 
 if(session.getItem("PopupState")===null) {
            $w('#BOX1').show()
            session.setItem("PopupState", "yes");
        }
 else {
            $w('#BOX1').hide()
            $w('#TXTouput').text="The pop-up have been already shown !!!"
        }
//  })
});

@russian-dima Thanks !!