WyldGynjer
MIS
Why is it when I first load my page that has the following code - that it tells me that Cookies are disabled - yet the cookie property of the navigator object in javascript tells me that cookies are enabled (which is correct - cookies are enabled.).
Then I refresh my page and this code says that cookies are enabled and displays the information that I had requested.
Cookie cookie = new Cookie("TestCookie", "Just a test of ability");
response.addCookie(cookie);
//CHECK TO SEE IF COOKIE WAS CREATED
Cookie[] allCookies = request.getCookies();
Cookie ourCookie = null;
if (allCookies!=null)
{
for (int i=0; i< allCookies.length; i++)
{
if (allCookies.getName().equals("TestCookie"))
{
ourCookie = allCookies;
}
}
}
if (ourCookie == null)
{
out.println("Cookies are disabled.<BR>");
} else {
out.println("Cookies are Enabled<BR>");
out.println("Cookie Version: " + ourCookie.getVersion());
out.println("<BR>Cookie Name: " + ourCookie.getName());
out.println("<BR>Cookie Maxage: " + ourCookie.getMaxAge());
out.println("<BR>");
}
Then I refresh my page and this code says that cookies are enabled and displays the information that I had requested.
Cookie cookie = new Cookie("TestCookie", "Just a test of ability");
response.addCookie(cookie);
//CHECK TO SEE IF COOKIE WAS CREATED
Cookie[] allCookies = request.getCookies();
Cookie ourCookie = null;
if (allCookies!=null)
{
for (int i=0; i< allCookies.length; i++)
{
if (allCookies.getName().equals("TestCookie"))
{
ourCookie = allCookies;
}
}
}
if (ourCookie == null)
{
out.println("Cookies are disabled.<BR>");
} else {
out.println("Cookies are Enabled<BR>");
out.println("Cookie Version: " + ourCookie.getVersion());
out.println("<BR>Cookie Name: " + ourCookie.getName());
out.println("<BR>Cookie Maxage: " + ourCookie.getMaxAge());
out.println("<BR>");
}