This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Here, I'm setting the maximum age for the cookie as 30*60 (30 minutes) but when I reach the second code , where I'm retrieving the cookie info, it gives me the maximum age as -1, that means cookie is not being stored.
I am not able to understand the output. What am I missing here? [ July 13, 2008: Message edited by: Khushbu Ghodasara ]
In your code you state, "Cookie  cookies = request.getKookies();", so the code cannot compile. Can you supply the actual code that is being used?
Joined: May 09, 2007
This is the actual code, but here it is not allowed to write getKookie() (read first K as C), due to security reasons, so they asked me to replace C with K in that particular method.
Joined: Jun 14, 2008
According to the api for the cookie class, "The browser returns cookies to the servlet by adding fields to HTTP request headers."
An associated rfc (2109) states:
4.3.4 Sending Cookies to the Origin Server
When it sends a request to an origin server, the user agent sends a Cookie request header to the origin server...
The syntax for the header is:
cookie = "Cookie:" cookie-version 1*((";" | ",") cookie-value) cookie-value = NAME "=" VALUE [";" path] [";" domain] cookie-version = "$Version" "=" value NAME = attr VALUE = value path = "$Path" "=" value domain = "$Domain" "=" value
It would therefore appear the maxAge value you are retrieving is one the container supplies when it instantiates a cookie it receives from the client. Since the setting of maxAge is the setting of a value that is used by the client, the fact that the "-1" is retrieved is not all that important.
You can verify that the maxAge is not in the request header using the Live HttpHeaders plugin/addon in the Firefox browser.