Hey guys,
Presently my script stores data in cookies using the standard procedures to set, get and delete cookies, like so:
[CODE]function setCookie(name, value, expires, path, domain, secure)
{
document.cookie= name + “=” + escape(value) +
((expires) ? “; expires=” + expires.toGMTString() : “”) +
((path) ? “; path=” + path : “”) +
((domain) ? “; domain=” + domain : “”) +
((secure) ? “; secure” : “”);
}
function getCookie(name)
{
var dc = document.cookie;
var prefix = name + “=”;
var begin = dc.indexOf(“; ” + prefix);
if (begin == -1)
{
begin = dc.indexOf(prefix);
if (begin != 0) return null;
}
else
{
begin += 2;
}
var end = document.cookie.indexOf(“;”, begin);
if (end == -1)
{
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain)
{
if (getCookie(name))
{
document.cookie = name + “=” +
((path) ? “; path=” + path : “”) +
((domain) ? “; domain=” + domain : “”) +
“; expires=Thu, 01-Jan-70 00:00:01 GMT”;
}
}
After studying cookies, I see that they have a unique functionality, in that setting the “document.cookie” property will not wipe its current value clean, but instead append or modify the necessary cookie values.
Now, what I’m looking to do is be able to have a variable in my document that will act exactly as “document.cookie” does when setting its value. Can anyone point me in the right direction of establishing this? I will be using ajax to save and recall userdata to a MySQL database. I am trying to clone document.cookie’s behavior as much as possible to make this transition away from cookies easier.
If you need any clarification, let me know. ?
Thanks,
David