Hi All,
I have created a simple JSP application having 2 pages CreateCookie.jsp and CheckCookie.jsp.
In CreateCookie.jsp, I am simply creating a new cookie using the following
code :
Cookie mycookie = new Cookie("user",username);
mycookie.setMaxAge(5);
response.addCookie(mycookie);
This page is being redirected to CheckCookie.jsp where I check the existance of the created cookie using the following code :
Cookie[] cookies = request.getCookies();
for (int i=0;i<cookies.length;i++)
{
String cookieName = cookies.getName();
String cookieValue = cookies[i].getValue();
if (cookieName.equalsIgnoreCase("user"))
{
System.out.println("**********************");
System.out.println(cookieName + " - " + cookieValue);
response.sendRedirect("welcome.jsp");
break;
}
else
{
System.out.println("**********************");
System.out.println(cookieName + " - " + cookieValue);
response.sendRedirect("logout.htm");
break;
}
}
The cookie is being created fine and being checked also fine.
However, when I manually block all cookies using my IE security options, and then run the JSP, I see that the cookie is still being created and stored on my computer.
What's the problem ?
Please Help !!