Session per user without login

Hey, I tried it, but that does not work either. Do you have any direction?

       $w("#buttonAddCompare").onClick((event) => {
 let $item = $w.at(event.context);
 let clickedItemData = $item("#datasetProduct").getCurrentItem();
 let productId = clickedItemData._id;

 if (local.getItem(productId) === null) {
                local.setItem('productId', productId);
                wixData.query("Compare")
                    .find()
                    .then((results) => {
 let numberOfItems = results.totalCount;
                        console.log(numberOfItems);
 if (numberOfItems === 3) {
                            $w('#compareErrorMes').show();
                        } else {
                            wixData.insert('Compare', clickedItemData)
                        }
                    })
            } else {
 let compareProduct = $item("#datasetCompare").getCurrentItem();
                console.log(compareProduct);
                $w("#datasetCompare").remove();
            }

 if (itemObj.categoryTitle === 'projectors') {
                $w('#compareBox').show();
            }
        });