It is possible to set of edit (re-setting) a cookie for storing information during a vistor session.
Create a Custom Html Tag with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<script> var cookieName = "nameOfTheCookie"; var cookieValue = "value"; var cookiePath = "/"; var expirationTime = 2628000; //For example one month in seconds (2628000) expirationTime = expirationTime * 1000; //Convert expirationtime to milliseconds var date = new Date(); //Create javascript date object var dateTimeNow = date.getTime(); //Get current time in milliseconds since 1 january 1970 (Unix time) date.setTime(dateTimeNow + expirationTime); //Set expiration time (Time now + one month) var expirationTime = date.toUTCString(); //Convert milliseconds to UTC time string document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path="+cookiePath; //Set cookie </script> |