javascript - Session cookie not expiring on browser tab close -
javascript - Session cookie not expiring on browser tab close -
i'm trying session cookie tracks whether user landing on homepage first time deleted when browser tab closed. however, seems visited cookie below keeps it's value of "yes" when browser tab closed. next time visit home page, script doesn't run redirect, since i'm checking "null" value visited cookie.
i'm using carhartl cookie script.
/* save textbook functionality */ $(function() { var cookie_name = 'textbook-cookie'; /* create cookie */ var visited = 'visited' /* track user has landed */ var path = window.location.pathname; $( ".save-textbook-cc1" ).click(function() { $.cookie(cookie_name, 'cc1', { expires: 365, path: '/' }); }); /*$( ".save-textbook-cc2" ).click(function() { $.cookie(cookie_name, 'cc2', { expires: 7, path: '/index.php' }); alert("textbook saved cc2!") $.cookie(visited, 'no', { expires: 7, path: '/index.php' }); });*/ $go = $.cookie(cookie_name); $visited = $.cookie(visited); if ($go == 'cc1' && $visited == null && path == '/') { $.cookie(visited, 'yes', { path: '/' }); window.location = "/core-connections-1"; } else { } });
"session" cookies (lifetime current session) persist until browser gets closed, not tab.
afaik, there no way alter because browser specific behaviour.
javascript jquery cookies session-cookies
Comments
Post a Comment