Hi,
I’m completely new to coding, so please excuse my ignorance.
I’m creating a Cookies pop up (as the app provided by Wix is not suitable for my needs). I have used the code provided in this article (although I’ve done it for local storage not session storage) in the Site tab:
https://support.wix.com/en/article/how-to-create-a-one-time-popup
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”);
// set flag for future visits
local.setItem(“firstTimePopupShown”, “yes”);
}
} );
However I would like to make it so that the pop up keeps coming up until the user clicks the Accept button, then no longer shows again after they have done that (to be GDPR compliant I believe specific consent needs to be given so I don’t want the Cookies box to go away until they have actually clicked). Using the coding in the article above, the user simply needs to refresh the browser to prevent the Cookies pop up from coming back.
Please can anybody let me know what code I need to add/change to make the pop up come up automatically on the user’s first visit and subsequent visits until they click Accept, make the actual clicking of the Accept button set the flag on the users local storage, and then prevent the pop up from showing again on future visits once the Accept button has been clicked?
Many thanks in advance,
Jane