the_groover
10-30-2003, 11:35 AM
Hi folks,
I am having some simple JavaScript Cookie issues. I am a newbie and am stuck on a simple validation script. Basically it is not working in the getCookie function. The idea is that I want to ensure that the user has a cookie on their system where the name is team_c.
Any guidance is much appreciated.
-Tim
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function setCookie(name, value, expdate) {
document.cookie = name + "=" + escape(value) + "; expires=" + expdate;
}
function getCookie(name) {
var dc = document.cookie;
if (dc == null){
alert('You do not have cookies set');
}
else{
location.href="index.html";
}
}
</SCRIPT>
</head>
<body>
<FORM>
<INPUT TYPE=button VALUE="Set A Cookie" onClick="setCookie('team_c','authentication',30)">
</FORM>
<FORM>
<INPUT TYPE=button VALUE="Get Cookie Info" onClick="getCookie('team_c')">
</FORM>
</body>
</html>
I am having some simple JavaScript Cookie issues. I am a newbie and am stuck on a simple validation script. Basically it is not working in the getCookie function. The idea is that I want to ensure that the user has a cookie on their system where the name is team_c.
Any guidance is much appreciated.
-Tim
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function setCookie(name, value, expdate) {
document.cookie = name + "=" + escape(value) + "; expires=" + expdate;
}
function getCookie(name) {
var dc = document.cookie;
if (dc == null){
alert('You do not have cookies set');
}
else{
location.href="index.html";
}
}
</SCRIPT>
</head>
<body>
<FORM>
<INPUT TYPE=button VALUE="Set A Cookie" onClick="setCookie('team_c','authentication',30)">
</FORM>
<FORM>
<INPUT TYPE=button VALUE="Get Cookie Info" onClick="getCookie('team_c')">
</FORM>
</body>
</html>