window.onload = () => {
const updateUserData = e => {
if (e.data && e.data.event === 'TADARIDA_sync_user_session') {
// Store the user data in the target domain
// this will ensure the session is saved in the target domain
Object.values(e.data.sessionData).forEach((entry)=>{
if(entry.data === null) {
window.localStorage.removeItem(entry.key);
return;
}
window.localStorage.setItem(
entry.key,
entry.type === "string" ? entry.data: JSON.stringify(entry.data)
);
})
}
};
window.addEventListener('message', updateUserData, false);
};