Filip, As for the actual code, what I gave below is all there is to the cookie code. The test case too would be what I described below.
I hadn't checked before, but we are facing this issue even with tomcat 5.0 when I do cookie.setVersion(1). The other thing I noticed with cookie.setVersion(1) on tomcat5.5.26 and tomcat5.0 is the cookie file is not being written under - C:\Documents and Settings\Sushil\Cookies. If you are looking for some specific code or need me to describe further, please let me know Thanks, Sushil -----Original Message----- From: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 27, 2008 1:49 PM To: Tomcat Users List Subject: Re: Incorrect cookie value in tomcat5.5.26 hi Sushil that scenario works just fine for me. you would have to show your actual code (and a test case) for me to analyze your actual problem Filip Sushil Vegad wrote: > Hello Filip, > > Please let me know your thoughts on this. > > Our scenario is: > We set the username in the cookie when the user logs in. I open a new > browser instance, log-in and the cookie is set. If I logout of the > application and return to login screen (on the same browser instance) the > cookie is found. > > PROBLEM: > If I use a NEW browser instance to go to the login page, the cookie is NOT > found. > > On login submit, we set the cookie - > Cookie cookie = new Cookie(Constants.REMEMBERME, username); > cookie.setVersion(1); > cookie.setMaxAge(Integer.MAX_VALUE); > response.addCookie(cookie); > > > On requesting the login page, we check if the cookie was set - > > Cookie cookies[] = request.getCookies(); > String username = ""; > for (int i = 0; i < cookies.length; i++) { > Cookie c = cookies[i]; > if (c.getName().equals(Constants.REMEMBERME)) { > username = c.getValue();//Set username in the login field > break; > } > } > > This code did not have an issue with tomcat 5.0 > Thanks, > Sushil > > > -----Original Message----- > From: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] > Sent: Monday, February 25, 2008 6:54 PM > To: Tomcat Users List > Subject: Re: Incorrect cookie value in tomcat5.5.26 > > what is your scenario, > > the following code worked for me, even though the browser doesn't send > up cookie version > > <% > javax.servlet.http.Cookie[] cs = request.getCookies(); > String value = null; > for (Cookie co : cs) { > if ("test".equals(co.getName())) value = co.getValue(); > > } > > javax.servlet.http.Cookie c = new > javax.servlet.http.Cookie("test","someemail=somedomain.com"); > c.setVersion(1); > c.setMaxAge(1000000); > response.addCookie(c); > > %> > done!<br/> > <%=value%> > > > > Sushil Vegad wrote: > >> Hello, >> >> cookie.setVersion(1) remembers the cookie only for the browser session. A >> new browser does not have access to the cookie >> >> We did cookie.setMaxAge(Integer.MAX_VALUE) but that doesn't help. >> >> Any thoughts please? >> >> Thanks, >> Sushil Vegad >> Technical Lead, Scheduling Project >> Serebrum Corporation - translating strategy into results >> Work: 609.777.3563 >> Cell: 732.216.4908 >> Email: [EMAIL PROTECTED] >> Conference Dial-in: 1-218-486-1300, Bridge: 427526 >> >> >> -----Original Message----- >> From: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] >> Sent: Monday, February 11, 2008 11:54 AM >> To: Tomcat Users List >> Subject: Re: Incorrect cookie value in tomcat5.5.26 >> >> not broken, corrected. the java doc says >> >> >> setValue >> >> public void *setValue*(String >> <http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html> newValue) >> >> Assigns a new value to a cookie after the cookie is created. If you >> use a binary value, you may want to use BASE64 encoding. >> >> With Version 0 cookies, values should not contain white space, >> brackets, parentheses, equals signs, commas, double quotes, slashes, >> question marks, at signs, colons, and semicolons. Empty values may >> not behave the same way on all browsers. >> >> *Parameters:* >> |newValue| - a |String| specifying the new value >> >> >> to fix this, all you need to do is >> >> cookie.setVersion(1); >> >> Filip >> >> Konstantin Kolinko wrote: >> >> >>> I guess the cause is the same as for tomcat 6.0.16. >>> See messages entitles "Cookies are broken in 6.0.16?". >>> >>> http://www.nabble.com/Cookies-are-broken-in-6.0.16--to15369118.html >>> >>> --------------------------------------------------------------------- >>> To start a new topic, e-mail: users@tomcat.apache.org >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >>> >>> >>> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]