Safari not loading Session variables

Question:
I have a dynamic page on my website where I am passing data in through Session data. Safari is not reading that data on the first load. I have to refresh to have the Session data available. Chrome works fine.

Product:
Wix Editor

What are you trying to achieve:
I am calling a dynamic page with with repeater of data in the CMS. I am allowing filters to be set on the data with the Session data creating a default filter. The Session data only loads when I refresh the page.

What have you already tried:
Tried to load the data in the repeater again. Tried to reload the page in code with wixlocation. Neither of these works.

Can you share the code that isn’t working?

Hello Anthony,

Here is the code. Thank you for your assistance!

Page #1: Dynamic page with the Repeater of data from the CMS table.

import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import { session } from ‘wix-storage’;
session.clear()

$w.onReady(async () => {

$w('#dataset1').onReady(() => {

$w("#searchInput").focus();
	console.log("dataset is ready")
    
    const today = new Date()
    $w("#prodFilter").value = today.getFullYear().toString()
    console.log($w("#prodFilter").value)

//  clear filters 
$w("#searchInput").value=""

    if($w('#searchInput').value === '') {
        $w("#dataset1").setFilter(wixData.filter().contains("subtitle",
        $w("#prodFilter").value))

        if($w('#prodFilter').value === 'All') {
                //$w("#prodFilter").value = null;
                $w("#dataset1").setFilter(wixData.filter().contains("subtitle",
        ""))
        }
    }

   

    $w("#prodFilter").onChange( (event) => {
        if($w('#prodFilter').value === 'All') {
                //$w("#prodFilter").value = null;
                $w("#dataset1").setFilter(wixData.filter().contains("subtitle", ""))
        } else {
             $w("#dataset1").setFilter(wixData.filter().contains("subtitle", 
        $w("#prodFilter").value))
    }})

    $w("#searchInput").onInput( (event) => {
       refreshRepeater($w("#searchInput").value)
        });

    });
    
    $w('#activitiesBtn').onClick((event) => {
            let $item = $w.at(event.context);
            console.log($item("#dataset1").getCurrentItem()); 
            let itemId = $item('#dataset1').getCurrentItem()._id;
            let itemFarm = $item('#dataset1').getCurrentItem().title;
            let itemYear = $item('#dataset1').getCurrentItem().subtitle;
            let itemFarmCode_id =   $item('#dataset1').getCurrentItem().farmCode._id;
            let itemFarmCode = $item('#dataset1').getCurrentItem().farmCode.farmCode;

            console.log(itemId, itemFarm, itemYear)
            session.setItem("itemID", itemId)
            session.setItem("itemFarm", itemFarm)
            session.setItem("itemYear", itemYear)
            session.setItem("itemFarmCode_id", itemFarmCode_id)
            session.setItem("itemFarmCode", itemFarmCode)

            console.log(itemId, itemFarm, itemYear, itemFarmCode_id, itemFarmCode)
            wixLocation.to('/crop-year-activities')
    })

});

function refreshRepeater(filter) {
if($w(‘#prodFilter’).value === ‘All’) {
$w(“#prodFilter”).value = null
}

wixData.query("Items")
    .contains("title", $w("#searchInput").value)
    .or(wixData.query("Items").contains("cropType", $w("#searchInput").value))
    .and(wixData.query("Items").contains("subtitle", $w("#prodFilter").value))
    
    .find()
    .then(results => {
        $w("#repeater1").data = results.items
    }
)}

Page 2: Second dynamic page connected to the items of the First page.

import wixMembers from ‘wix-members’;
import { currentMember } from ‘wix-members-frontend’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import { session } from ‘wix-storage’;

$w.onReady(async () => {
const today = new Date();
const member = currentMember.getMember();
const itemID = session.getItem(“itemID”);
const itemFarm = session.getItem(“itemFarm”);
const itemYear = session.getItem(“itemYear”);
const itemFarmCode =session.getItem(“itemFarmCode”)
console.log(itemFarm, itemYear);

await $w('#dataset1').onReady( () => {
    console.log("dataset is ready")  

    $w("#farm").text = itemFarm

    // NOTE:  this code throws an error,  because the variables are still Null rather than having data.   Only a manual refresh on the URL works to retrieve the data.

    $w("#dataset1").setFilter( wixData.filter().contains("title", itemFarm )
           .and(wixData.filter().contains("cropYear", itemYear)))

    $w("#editBtn").onClick( (event) => { 
        const $item = $w.at(event.context); 
        const itemId = event.context.itemId;
        const data = $w("#repeater1").data;
        const itemData = data.find((item) => item._id === itemId);
        const index = data.findIndex((item) => item._id === itemId);
    })

});
})