troubleshooting Question

JS cookie redirect problem

Avatar of vrmetro
vrmetroFlag for United States of America asked on
JavaScript
3 Comments1 Solution283 ViewsLast Modified:
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");
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros