About Cookies

Applies to IE Browser publications.

In HTML Executable, cookies may not work properly. Moreover, as they are not enough secure nor persistent, they are replaced by global variables.

Global variables can be used by HEScript and JavaScript scripts to share data and store values in the publication. They are better and more secure than cookies. If you were using cookies in your JavaScript code, we recommend you to switch to global variables.

JavaScript code to replace cookies with global variables

imgFor instance, the following JavaScript function creates a cookie:

function createCookie(name,value,days) {

if (days) { var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); } else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

In a HTML Executable publication, you can replace it with:

function createCookie(name,value,days) {
	  window.external.SetGlobalVariable(name, value, true);
}

imgThe following function reads the value of a cookie:

function readCookie(name) {

var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) { var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length,c.length);
}
return null;
}

You can use this instead:

function readCookie(name) {

return window.external.GetGlobalVariable(name, '');
}

img Learn more about global variables