Cookies Code does not work as it should. Any help?

Hi Cracks :wink:

I have used coding from other examples from Forum.
Partially, it works, but not the way, as it should work.

PROBLEMS

  1. Lightbox-Cookies always pop up, whenever I come back to page, where the code is embedded
  2. Lightbox-Cookies does not pop up on other pages of the site, when I land there first.

GOAL
should be that Lightbox will pop up on whichever page somebody lands first, across the whole site.
Any help?

PAGE CODE


import {local} from ‘wix-storage’;
import wixWindow from “wix-window”;
$w.onReady( function () {
// flag is not found
if (!local.getItem(“firstTimePopupShown”)) {
// open popup
wixWindow.openLightbox(“Cookies”);
}
} );

SITE


import {local} from ‘wix-storage’;
import wixWindow from “wix-window”;
import wixLocation from “wix-location”;
export function AcceptCookies_click(event, $w) {
// set flag for future visits
local.setItem(“firstTimePopupShown”, “yes”);
wixWindow.lightbox.close();
}