Unable to get session data in Lightbox

I have a page: Edit Your Registrations that has a button for uploading photos. This button loads a Lightbox called Upload Registry Photos that contains a Cloudinary Upload Widget. When the user closes the widget it sends me an email notification using sendgrid. All this is working fine. What I am trying to do is add the uploading user’s email to the message.

For the calling page: Edit Your Registrations code is as follows:

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import {local, session} from ‘wix-storage’;

$w.onReady( function () {
let user = wixUsers.currentUser;
let userEmail;
let userId = user.id;
.then( (email) => {
userEmail = String(email);
$w(‘#userEmail’).text = userEmail;
).then(() => {
console.log(userEmail) <========== CORRECTLY DISPLAYS EMAIL
} );

In the Lightbox: I have this code:

import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;
import {local, session} from ‘wix-storage’;
import {lightbox} from ‘wix-window’;

$w.onReady( function () {
//TODO: write your page related code here…
let replyto = ‘#text113’;
let regitem = lightbox.getContext();
replyto = session.getItem(“userEmail”); // “value”
console.log(replyto); <==============LOGS “undefined”

export function closeButton_click(event, $w) {
const subject = Photos Uploaded To Cloudinary;
const body = New Photos Just Added By \rEmail: replyto

sendEmail(subject, body)
.then(response => console.log(response));

What am I missing here?


This issue has been solved.