javascript- unable to find the cookie?
<html>
<head>
</head>
<body>
<script type="text/javascript">
function check_user( )
{ name = cookie_read('name') if (name!=null)
alert("Welcome back" +name)
else { name=prompt("Enter your name")
if (name!=null && name!="") { cookie_create("name",name,7)
}
}
document.cookie = 'name=John Smith; expires=Thu, 9 Oct 2008 20:47:11 UTC; path=/';
}
function getCookie( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 )
{
return null;
if (document.cookie.length>0)
{
s=document.cookie.indexOf ("name=");
if (s != -1)
{
s2 = s + 5;
e=document.cookie.indexOf (";",s2);
if (e==-1)
e=document.cookie.length;
myvalue = (unescape.document.cookie.substring (s2,e);
}
}
return "";
}
}
|