-2

Hi I have made a program in which we have to read cookies through javascript but I am facing a problem in it. And I am unable to understand where the problem is? Please help me understand the same.

<html>
<head>
<title>read cookies</title>

<script language="javascript">
function gettime(){
if(document.cookie)
{
index=document.cookie.indexOf(cookie_name);
if(index!=-1)
countbegin=(documnet.cookie.indexOf("=",index);
countend=document.cookie.indexOf(";",index);
if(countend == -1)
countend=document.cookie.length;
}
count=document.cookie.substring(countbegin,countend);
if(count==1)
return(count+"time");
}
else
{
return(count+ "times");
}
}}
return("0 times");
}
</script>
</head>
</html>
3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by network18
0

Hi I have made a program in which we have to read cookies through javascript but I am facing a problem in it. And I am unable to understand where the problem is? Please help me understand the same.

<html>
<head>
<title>read cookies</title>

<script language="javascript">
function gettime(){
if(document.cookie)
{
index=document.cookie.indexOf(cookie_name);
if(index!=-1)
countbegin=(documnet.cookie.indexOf("=",index);
countend=document.cookie.indexOf(";",index);
if(countend == -1)
countend=document.cookie.length;
}
count=document.cookie.substring(countbegin,countend);
if(count==1)
return(count+"time");
}
else
{
return(count+ "times");
}
}}
return("0 times");
}
</script>
</head>
</html>

You did not used the braces properly in the javascript function.
Use the proper indentation, it will help to debug the code.
Starting braces '{' are 3 and the ending braces '}' are 6 :)

Edited by network18: n/a

-1

I agree to you but when i showed this code to my senior he said that substring (line 16)should not come there its wrong noe tell me what should i do? and i am unable to find answer through google as well

Votes + Comments
Read what network18 has mentioned. If you can't understand what he is saying, ask your senior.
0
<html>
<head>
<title>read cookies</title>

<script language="javascript">
function gettime()
{
if(document.cookie)
{
index=document.cookie.indexOf(cookie_name);
if(index!=-1)
{
countbegin=(document.cookie.indexOf("=",index);
countend=document.cookie.indexOf(";",index);
if(countend == -1)
countend=document.cookie.length;
}
count=document.cookie(countbegin,countend);
if(count==1)
return(count+"time");
}
else
{
return(count+ "times");
}

return("0 times");
}
</script>
</head>
</html>

Edited by namratakakkar84: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.