Problems with retrieving the correct cookie in Java
Posted
by Spines
on Stack Overflow
See other posts from Stack Overflow
or by Spines
Published on 2010-04-14T02:18:40Z
Indexed on
2010/04/14
2:23 UTC
Read the original article
Hit count: 361
When I retrieve the cookies in my java servlet, all of the values from getPath() are null.
So if a cookie with the same name is set in directory /foo, and at the root directory, I retrieve two cookies with the same exact name, but I can't differentiate them because getPath() returns null for both.
I looked in firebug and saw that firefox was not sending anythign for the path.
My application uses a "rememberme" cookie with the path set to "/". Everything works fine as long as there is only one cookie with name rememberme. But if somehow another cookie gets set with the same name on a different path like /foo, then my application won't know which one is the one I set for the root.
How can I differentiate the cookies? Do I need to worry about a cookie existing with the same name in a subdir, or can I just assume there will be only the one I set?
© Stack Overflow or respective owner