Link to home
Start Free TrialLog in
Avatar of vrmetro
vrmetroFlag for United States of America

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
// 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");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Can someone please help edit this code so it will only check to see if cookie "COOKIENAME" is presen
If the name of your cookie is actually "COOKIENAME" then change:
if( readCookie("User") )


to:
if( readCookie("COOKIENAME") )
Avatar of vrmetro

ASKER

perfect, thanks.