I have a cookie that is being set by this function (page calendar.html):
function bookit(id){
document.cookie='eventid' + "=" + id;
document.location.href ="/sys/account.php";
}
After that the users is redirected to account.php so he can sign in and the id is used on that page and this is what I have on account.php:
function getCookieValue(key)
{
currentcookie = document.cookie;
if (currentcookie.length > 0)
{
firstidx = currentcookie.indexOf(key + "=");
if (firstidx != -1)
{
firstidx = firstidx + key.length + 1;
lastidx = currentcookie.indexOf(";",firstidx);
if (lastidx == -1)
{
lastidx = currentcookie.length;
}
return unescape(currentcookie.substring(firstidx, lastidx));
}
}
return "";
}
alert(getCookieValue("eventid"));
well the dilemma is : when I refresh calendar.html the alert returns 51 for example which is the value of that event, BUT when i refresh account.php it says: NULL I have tried a jquery cookie plugin, same results so I went back to basic javascript, its driving me insane at this point I dont understand how to pass that value. I figured using cookies would be the right method - but its not working.any suggestions please? I have a javascript debugger my code has no errors.