Highlighted

I want to set a cookie when a specific jQuery selector is visible (#total-price), but I want to set this only for that specific session. And want to reset/clear the cookie when the session ends. How can you set the cookie expiration ?

 
3 REPLIES 3
Highlighted

I want to set a cookie when a specific jQuery selector is visible (#total-price), but I want to set this only for that specific session. And want to reset/clear the cookie when the session ends. How can you set the cookie expiration ?

Employee Emeritus
Pradeep, Be default, cookies are deleted after the session. So if you just leave the expiration date blank when setting the cookie, it will be deleted at the end of the session. Example: document.cookie="username=JohnDoe";
Highlighted

I want to set a cookie when a specific jQuery selector is visible (#total-price), but I want to set this only for that specific session. And want to reset/clear the cookie when the session ends. How can you set the cookie expiration ?

Thank you Jared for letting me know. Also just to confirm is below the correct way to set the cookie ? ("tot_price_in_cart " is the variable that captures the value) utag.loader.SC("utag_main", {"total_price_cookie" : tot_price_in_cart"});
Highlighted

I want to set a cookie when a specific jQuery selector is visible (#total-price), but I want to set this only for that specific session. And want to reset/clear the cookie when the session ends. How can you set the cookie expiration ?

Employee Emeritus
Pradeep, You would use something like: {code:javascript} utag.loader.SC("utag_main", {"total_price_cookie": tot_price_in_cart+";exp-session"});{code} This will set the expiration date of the cookie to a session. NOTE: The Tealium version of a session follows the analytics world version, meaning that the cookie is deleted only after 30 minutes of inactivity on the site.