Working with non tealium cookies on a custom container

Silver Contributor
Silver Contributor

I would like change the expiration date in a non-Tealium cookie using utag.loader.SC is it posible?

 

My cookie "cookieTemp" has a value = 1; I put that value using that expresion: utag.loader.SC("cookieTemp",1);

 

How Could I change the expiration date using utag.loader.SC if I want that my expiration date to be 30 minutes.

 

I have seen that sintaxis here for Tealium cookies but I don't know how to used it in that case.

 

utag.loader.SC("utag_main",{"mycookie123":"testing123;exp-1351111959896u"});

 

2 REPLIES 2
Highlighted

Working with non tealium cookies on a custom container

Tealium Employee

@sara

 

So you can either add your cookie on to the main utag_main cookie, or you can create your own utag_* cookie,

 

Either way, you can the end result will look something like:

 

 

utag.loader.SC("utag_main", {"cookie" : "1;exp-"+(new Date().getTime() + 30000)+"u"});

 When you read back the cookie:

 

 

 

utag.loader.RC("utag_main");
> {
"cookie" : "1",
"v_id": "0154ba3a1df200223d93373a109805078002807000bd0",
"_sn": "9",
"_ss": "0",
"_st": "1463742924792",
"ses_id": "1463740204884",
"_pn": "4"
}

 

 

After the 30 minutes have expried, you will see the same object as above, but without the cookie, property.

 

utag.loader.RC("utag_main");
> {
"v_id": "0154ba3a1df200223d93373a109805078002807000bd0",
"_sn": "9",
"_ss": "0",
"_st": "1463742924792",
"ses_id": "1463740204884",
"_pn": "4"
}

 

NOTE: You will still see the value present in the actual cookie, until utag_main is updated with utag.loader.SC again.

 

If you want to write a cookie, that will expire and be removed after 30 mins, you can either use the persist data extension 
https://community.tealiumiq.com/t5/Tealium-iQ/Persist-Data-Value-Extension/ta-p/13623

 

Selecting hours and typing in "0.5".

 

Other wise you can write a cookie directly in JavaScript with:

 

document.cookie = "<cookie name>=<value>;path=/;domain=" + utag.cfg.domain + ";expires=" +(function() {var d = new Date();d.setTime(d.getTime() +1800000);return d.toGMTString();})();

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Highlighted

Working with non tealium cookies on a custom container

Bronze Contributor
Bronze Contributor
NOTE: the Cookie set in this is example is 30 secs not minutes