tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: cookies
Date Mon, 06 Aug 2007 21:01:51 GMT
Hash: SHA1

Tony, wrote:
> I just did a responses to this and somehow it got lost ;-(

I hate it when that happens. :(

>  Cookie oreo;

Very clever ;)

That code looks fine, by the way. The fact that cookies.length is 1
probably means that the cookie was never sent, rather than you writing
bad code. Your code looks fine, too. I was looking to see if you did
anything like if(cookie.getName() == "UserLevel") which, of course,
wouldn't work.

> You can see I have a couple debug statements. Length is 1
> and the only cookie is JSESSIONID 034B86006263B7E9E68EE7A660DC728E.
> Though I do see it in the catalina log and the edit->preferences (UserLevel 0).

What does that mean?

> The cookie-setting is not mine, but rather the person who left. It is kind of complicated
> so I will just show the relative parts (you can ignore the else part). As I said it shows
> in the log file and edit->preference
> if(err.errcode == 0){
>  Cookie cok = new Cookie("UserLevel",sUserLevel);
>  System.out.println( "Added COOKIE UserLevel: " + sUserLevel );
>  response.addCookie(cok);

Hmm... no "path" set on the cookie.

Did you verify that the cookie is being sent to the client correctly
(after the addCookie call above)? Use something like LiveHTTPHeaders, or
even the RequestDumperValve on the server-side to see what's up.

For good measure, you might want to modify the cookie-setting code to do

Cookie cok = new Cookie("UserLevel", sUserLevel);

The servlet API doesn't require the path, but doesn't say what the
default path is. Perhaps it is effectively "/". Observation of the
request and response headers will be requires in order to understand
what's going on.

- -chris

Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla -


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message