I have a .jsp page that highlights the usefulness of cookies. This simple page asks you for your name and stores it in a cookie that lasts for about 1 hour. However the part I don't understand right now is how the cookie sets. This is during the evaluation of its existence on the client machine. Here is the code:
Code:
//Create the cookies object which is an array of cookies available to this page.
Cookie[] cookies = request.getCookies();
//Loop through the array and find the NameCookie cookie
for (int i = 0; i < cookies.length; i++) {
nameCookie = cookies[i];
if (nameCookie.getName().equals("NameCookie")) {
cookieValue = nameCookie.getValue();
//The user's been here before!
cookieExists = true;
}
}
Now, the cookies array? What are the contents of this array? I believe its checking to see if a cookie by the name of "nameCookie" exists? But what values is it referencing? So cookie.length is how long?
Just in case someone wants to go the marathon explanation here is the entire script. NOW!! Beware!!
This page gives some problems to run. I only got it to run in oracle's JDeveloper 9i. This ide is very easy and convenient to use I love it. Thanks in advance for the help.