How to keep Checkboxes checked even after leaving the page/site?

Hello, I have a wedding planning business and I recently added an online wedding checklist for clients/visitors to access once they login to my website (after paying for this checklist). This checklist begins at 12 months prior to their wedding date and includes a “to do list” of items they need to complete for their wedding planning. I have listed each item on this list as a single checkbox (organizing them by 12 months out, 9 months out, 6 months out, etc.). What I would like to happen is for each checkbox a visitor checks, to stay checked - even when they leave the site/page altogether. What is happening currently is that once a visitor leaves the page with the checklist (checkboxes), all of the checkboxes that they have checked are now left blank/unchecked again. This makes it impossible for them to track any progress with their wedding planning. I am not familiar with using code at all. However, I did see a similar question on this forum from another user and copied the code they used, but this code did not work for me. (see code below). Is there something specific I need to add to this code for my checkboxes to stay checked once clicked?

Code:
import {session} from ‘wix-storage’;

$w.onReady( function () {
let val = session.getItem(‘array’);
if (val) {
let newArray = JSON.parse(val);
if (newArray.length > 0) {
newArray.forEach( (item) => {
$w(${item}).disable();
});
}
}
});

var array = ;

export async function checkbox1_change(event) {
if ($w(“#checkbox1”).checked === true ) {
$w(“#checkbox1”).disable();
await array.push(‘#checkbox1’);
let valve = JSON.stringify(array);
session.setItem(‘array’, valve);
}
}

export async function checkbox2_change(event) {
if ($w(“#checkbox2”).checked === true ) {
$w(“#checkbox2”).disable();
await array.push(‘#checkbox2’);
let valve = JSON.stringify(array);
session.setItem(‘array’, valve);
}
}

I have also done some research and it sounds like I need to have a local storage option added to my code on the webpage with the checkboxes and the code I found for this option is here:
import {local} from ‘wix-storage’ ;

// …

local.setItem( “key” , “value” );

What am I doing wrong? Can someone please help explain this to me in lay terms (haha I have no experience with coding so I need someone to spell it out to me).

Here is a screenshot of my website with the checkboxes:

1 Like

Hi,

When someone clears their internet browser’s cookies, it clears the information that is stored in the visitor’s local storage. Because of this, I don’t recommend storing the checkbox data that were checked within local storage on your site.
I can recommend creating a data collection that submits and stores the checkboxes that were checked on the page so that when someone visits that page after logging in, it queries the data collection with the information on which checkboxes should be checked and displays it on the page depending on who is logged in.

Here are some links to the Corvid API reference that may help you in this case:
CheckBox API reference Info
Wix Data API Reference Info

Best regards,
Edward

Hi, I have created a “test” database and linked a checkbox to this database, and have created a dataset to try to link to this as well. I am still not having any luck with keeping my checkboxes in a checked state once leaving the page and returning again. I have no idea what I am doing, I have researched all of the Corvid forums and aticles about API and watched tutorial videos but I can’t seem to find anything pertaining to what i would like to do. plese help!