Search the Community
Showing results for tags 'find cookie'.
-
Thank you for taking the time to help me! My "check for cookie" code doesn't work. It doesnt show any errors or do anything. Can someone help me understand what I am doing wrong. I am trying to create the code to check for a cookie. If it doesn't exist I want it to display a <div>information</div>. My code to check for a cookie is called usercheck_cookie.html Here is my code to check for a username: <script> function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function checkCookie() { var User_ID=getCookie("User_ID"); if (User_ID!=null && User_ID!="") { alert("Welcome again " + username); } else { alert("You are not a user!); echo "<html><div id="Signup" style="position:fixed;width:1000px;height:500px;top:300px;left:50%;background-color:#220916;"> </div></html>"; } } </script> Here is how I set it into my index.shtml: <!DOCTYPE html> <html> <head> <title>Diamond Book Club</title> <!--#include virtual="usercheck_cookie.html" --> </head> <body onload="checkCookie()"> // and the rest of my website is below Sincerely, Brett Hartel
- 1 reply
-
- checking cookies
- cookie
-
(and 3 more)
Tagged with: