Click to See Complete Forum and Search --> : Where do all the cookies go?


anw
07-22-2007, 05:50 PM
Could someone please tell me how cookies are scoped and managed? I have a web application, implemented with Tomcat, and in some parts of the application I can get cookies, and in others not. The header HOST value is the same (I've printed it out), so I don't know how to get at these cookies.

What I'm trying to do is implement an autologin type feature. When the user logs on manually (via a page like "http://host.com/login.jsp"), the user is validated via a database lookup in a servlet and userid/password cookies are stored (by this servlet, with a uri in the jsp's form like "/appname/ManualLogin"). The login.jsp page populates the form fields (${cookie.userid.value}) from the cookies with no problem. At logon, a user bean is stored. When the user goes to an internal page (like "http://host.com/UserData/userid/home.jsp"), if the user bean is not set, he will be redirected to an autologin servlet (from the jsp page, this is <jsp:forward page="/AutoLogin" />. This servlet attempts to get the userid/password cookies from the request. The autologin servlet does not see the cookies.

anw
07-22-2007, 09:43 PM
OK, evidently where I was setting the cookies grabbed a default path for the cookies. When I set the cookies and explicitly set a path of "/" (Cookie.setPath("/")), they are all available.

Thanks to anyone who may have looked at this.

Regards,
Allen