Wix storage

I have been debugging this situation for hours, and browse the web to see if someone has stumbled with similar problem. I have a lightbox , where the user enter email and password and click button go. On the go button click function, I take the email and password from the userinput elements and store then in the store session, then close the lightbox and navigate to another page. On the page, I show the email and the data from a data collection corresponding to the user. Problem: the first time I arrive at the page ‘nada’ zero, no data is shown, but if I run it again the data appears on the page. i was able to see that the session items on the first call to the page are null. I have done async wait, nothing.
can somebody shine some light this way please. It will be appreciated. Thanks

here is the code of the lightbox

import wixData from “wix-data”;
import wixLocation from “wix-location”;
import wixWindow from “wix-window”;
import {session} from ‘wix-storage’;

export async function buttonLogin_click(event, $w) {
await session.setItem(‘isLogin’, ‘true’);
await session.setItem(‘eMail’, $w(’ #inputEmail ‘).value.toString());
await session.setItem(‘password’, $w(’ #inputPassword ‘).value.toString());
wixWindow.lightbox.close();
wixLocation.to (’/REGISTRATION’);
}

here is the code of the registration page.
import {generateRefCode,insertRefCode,insertMemberRecord} from ‘backend/aHideCode’;
import wixData from ‘wix-data’;
import {session} from ‘wix-storage’;
import wixLocation from “wix-location”;

$w.onReady( async function () {
if (session.getItem(‘eMail’)=== null ) {
// do nothing $w(’ #text2 ‘).text = ‘: doing nothing’; }
else {
if (session.getItem(‘isLogin’).toString() === ‘true’ ) {
let eMail = session.getItem(‘eMail’);
let password = session.getItem(‘password’);
session.clear();
session.setItem(‘isLogin’, false );
await wixData.query(“dbMembers”)
.eq(“mEmail”, eMail)
.and(wixData.query(“dbMembers”)
.eq(‘mPassword’, password))
.find()
.then( (results) => {
if (results.items.length > 0) {
$w(’ #inputEmail ‘).value = results.items[0].mEmail;
$w(’ #inputFirstName ‘).value = results.items[0].mFirstName;
$w(’ #inputLastName ‘).value = results.items[0].mLastName;
$w(’ #inputState ‘).value = results.items[0].mState;
$w(’ #inputZipCode ‘).value = results.items[0].mZipCode;
} else {// will deal with this section later } } )
. catch (error => {console.log(error);}); }
else {
$w(’ #inputEmail ‘).value = null ;
$w(’ #inputFirstName ‘).value = null ;
$w(’ #inputLastName ‘).value = null ;
$w(’ #inputState ‘).value = null ;
$w(’ #inputZipCode ‘).value = null ;
$w(’ #boxGenerateCode ‘).collapse();
$w(’ #inputEmail ‘).placeholder = ‘email’;
$w(’ #inputFirstName ‘).placeholder = ‘First Name’;
$w(’ #inputLastName ‘).placeholder = ‘Last Name’;
$w(’ #inputState ‘).placeholder = ‘State’;
$w(’ #inputZipCode ‘).placeholder = ‘Zipcode’;
} }
wixLocation.to (’/REGISTRATION’); })

Greetings,

It would be better if you could share the code for the lightbox and the page navigated to. That will give you a better chance of one of us being able to help.

After the turbo upgrade I had all kinds of issues with lightboxes (including the login dialog).

Lightbox Errors confirmed by Corvid, but no fix yet.

I moved my login code from a lightbox to a regular page - everything works as before.

Furthering on from Anthony’s comment, that we really need to see your code and be able to gather more details ourselves to help you more.

Is this lightbox where you are taking the email and password user inputs from, is this your custom login lightbox?

If it is then, why do you really need to have their details saved in local, session or memory storage and then have it retrieved when you navigate from the lightbox to the page?

As they would already be logged in themselves, then you could simply make the page that you navigate to a page with a dataset on that page, or it has links to a dataset, that just reads and shows the logged in members info from the dataset and shows this on the page.

Just use current user from Wix Users to do this:
https://www.wix.com/corvid/reference/wix-users.html
https://www.wix.com/corvid/forum/community-discussion/guest-passwords-and-member-passwords

Similar to a members profile page:
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Or you can do something very simple and all without code by adding Wix Members Area to your website and having each member have their own My Account page all ready for them:
https://support.wix.com/en/article/about-members-area
https://support.wix.com/en/site-members/setting-up-a-members-area

Otherwise, if you are still wanting to have data sent from a lightbox to a page, then have a look at the Wix API’s for open lightbox and close lightbox that are listed below, both of which contain an example of the code needed for your website.

For more info about the Wix API’s, follow the links below:
https://www.wix.com/corvid/reference/wix-storage.html
https://www.wix.com/corvid/reference/wix-window.html#openLightbox
https://www.wix.com/corvid/reference/wix-window.lightbox.html#close
https://www.wix.com/corvid/reference/wix-window.lightbox.html
https://www.vorbly.com/Vorbly-Code/WIX-CODE-SENDING-DATA-TO-LIGHTBOX
https://www.vorbly.com/Vorbly-Code/WIX-CODE-PASSING-DATA-BETWEEN-PAGES?lightbox=dataItem-jip2do70_items_2

Hi Anthony, thanks for replying. I am trying to learn wix , feel free to correct anything that is redundant. here is the code of the lightbox

export async function buttonLogin_click(event, $w) {
// wixWindow.lightbox.close();
await session.setItem(‘isLogin’, ‘true’);
await session.setItem(‘eMail’, $w(‘#inputEmail’).value.toString());
await session.setItem(‘password’, $w(‘#inputPassword’).value.toString());
wixWindow.lightbox.close();

wixLocation.to('/REGISTRATION'); 

}

here is the code of the registration page.

$w.onReady( async function () {

if (session.getItem(‘eMail’)=== null ) {
// do nothing
$w(‘#text2’).text = ‘: doing nothing’;
} else {
if (session.getItem(‘isLogin’).toString() === ‘true’ ) {
let eMail = session.getItem(‘eMail’);
let password = session.getItem(‘password’);
session.clear();
session.setItem(‘isLogin’, false );
await wixData.query(“dbMembers”)
.eq(“mEmail”, eMail)
.and(wixData.query(“dbMembers”)
.eq(‘mPassword’, password))
.find()
.then( (results) => {
if (results.items.length > 0) {
$w(‘#inputEmail’).value = results.items[0].mEmail;
$w(‘#inputFirstName’).value = results.items[0].mFirstName;
$w(‘#inputLastName’).value = results.items[0].mLastName;
$w(‘#inputState’).value = results.items[0].mState;
$w(‘#inputZipCode’).value = results.items[0].mZipCode;

                                } 

else {// will deal with this section later

                                  } } 
                             ) 
                        . **catch** (error => {console.log(error);}); 

}  **else**  { 
        $w('#inputEmail').value =  **null** ; 
        $w('#inputFirstName').value =  **null** ; 
        $w('#inputLastName').value =  **null** ; 
        $w('#inputState').value =  **null** ; 
        $w('#inputZipCode').value =  **null** ; 
        $w('#boxGenerateCode').collapse(); 
        $w('#inputEmail').placeholder = 'email';  
        $w('#inputFirstName').placeholder = 'First Name'; 
        $w('#inputLastName').placeholder = 'Last Name'; 
        $w('#inputState').placeholder = 'State'; 
        $w('#inputZipCode').placeholder = 'Zipcode'; 


       } 

}
wixLocation.to(‘/REGISTRATION’);
})

I will try that. let you know how it goes, thanks.

hi, if I would have a kentucky bourbon , I share it with you :slight_smile: I am not using the custom login because I am just learning this , so I want to have some control of what I am doing. I will try later to do it that way. thanks for the reference, I will check those wix API’s

@imars7

Where are your imports and onReady on your lightbox code and where are your imports for the page code?

Have a read of the api’s:
https://www.wix.com/corvid/reference/wix-data.html#query
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html
https://www.wix.com/corvid/reference/wix-storage.html
https://www.wix.com/corvid/reference/wix-location.html
https://www.wix.com/corvid/reference/wix-window.html#openLightbox
https://www.wix.com/corvid/reference/wix-window.lightbox.html#close

@givemeawhisky I edit my post with the imports thanks

@givemeawhisky lol all that readings means that all the coding posted above is wrong?

I follow your advise and move the login code from lightbox to a regular page and it works fine. Thanks !!!