I have a cookie that contains a name=value pair. I want to change the value. I can retrieve the value with the following code, but I do not know how to change it.
Thanks in advance.
function changeCookie() {
var intStart = ((document.cookie.indexOf("CookieName=", 0)) + 12);
if (intStart == -1)
{
alert('Cookie not found.');
return null;
}
else
{
var intEnd = intStart + 11;
var strCookie = document.cookie.substring(intStart, intEnd);
if (strCookie == 'CookieValue')
return strCookie;
else
return null;
}
}
Writing a cookie with JavaScript is fairly straight forward, but in this case I need to be able to modify the value for the individual name=value pair.
If you can provide any more insight I would greatly appreciate it.