vrmetro
asked on
JS cookie redirect problem
Hello,
I am using the script below to only see if a cookie is present, if so, redirecting to the page. I believe this is setting a cookie as well. Can someone please help edit this code so it will only check to see if cookie "COOKIENAME" is present, if so redirect to the url?
Thank you
I am using the script below to only see if a cookie is present, if so, redirecting to the page. I believe this is setting a cookie as well. Can someone please help edit this code so it will only check to see if cookie "COOKIENAME" is present, if so redirect to the url?
Thank you
// page to go to if cookie exists
go_to = "index.php?option=com_content&view=article&id=91&Itemid=73";
function readCookie(FindWhere){
var start = document.cookie.indexOf(COOKIENAME);
if (start == -1){
document.cookie = "User=yes"; expires=" + ged(num_days)";
} else {
window.location = go_to;
}
}
readCookie("User");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect, thanks.
If the name of your cookie is actually "COOKIENAME" then change:
if( readCookie("User") )
to:
if( readCookie("COOKIENAME") )