tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: cookies
Date Mon, 06 Aug 2007 21:01:51 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tony,

tony.chamberlain@lemko.com 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
up
> 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
this:

Cookie cok = new Cookie("UserLevel", sUserLevel);
cok.setPath(request.getContextPath());
response.addCookie(cok);

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGt4w/9CaO5/Lv0PARAu6kAJ4mbMDU2cEiTCd3ZTmpOKKgYWyoogCeK4Ds
gJZ6IWEJxTbjuEpYaTDh+Dg=
=i1q5
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message