internet explorer - Using javascript to set cookie in IE -
document.cookie= "cookiename=cookievalue; expires=mon,12jun2015:00:00:00; path=/;"
i run script on internet explorer 10 doesn't share cookie between 2 ie tab. when remove "expires" properties seem working :
document.cookie= "cookiename=cookievalue ;path=/;"
but don't want remove "expires" properties. how resolve problem ?
i have used code since mid '90s - has worked in browsers on platforms far
include file , use
setcookie("name","value",expirydate,"/");
// cookie.js file var cookietoday = new date(); var expirydate = new date(cookietoday.gettime() + (365 * 86400000)); // year /* cookie functions bill dortsch */ function setcookie (name,value,expires,path,thedomain,secure) { value = escape(value); var thecookie = name + "=" + value + ((expires) ? "; expires=" + expires.togmtstring() : "") + ((path) ? "; path=" + path : "") + ((thedomain) ? "; domain=" + thedomain : "") + ((secure) ? "; secure" : ""); document.cookie = thecookie; } function getcookie(name) { var search = name + "=" if (document.cookie.length > 0) { // if there cookies var offset = document.cookie.indexof(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value var end = document.cookie.indexof(";", offset) // set index of end of cookie value if (end == -1) end = document.cookie.length return unescape(document.cookie.substring(offset, end)) } } } function delcookie(name,path,domain) { if (getcookie(name)) document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=thu, 01-jan-70 00:00:01 gmt"; }
Comments
Post a Comment