| Author |
about Cookies
|
naresh kavya
Greenhorn
Joined: Jul 15, 2006
Posts: 5
|
|
Hi I hava problem with cookies.I set cookie age as 40000 but while executing it is showing age as -1.plese provide the solutions. Tks in advance. cade Cookie c1 = new Cookie("cu",cuname); Cookie c2 = new Cookie("cp",cpwd); c1.setMaxAge(4000000); c2.setMaxAge(4000000); resp.addCookie(c1); resp.addCookie(c2); for (int i = 0; i<=cookies.length; i++) { c[i] = cookies[i]; name[i] = c[i].getName(); value[i] = c[i].getValue(); System.out.println("cookie age is"+c[i].getMaxAge()); }
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
I don't see where you're creating the cookies variable.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
naresh kavya
Greenhorn
Joined: Jul 15, 2006
Posts: 5
|
|
hi ben tks for response i creted cookies as Cookie[] c=new Cookie[10;
|
 |
naresh kavya
Greenhorn
Joined: Jul 15, 2006
Posts: 5
|
|
and Cookie[] cookies = request.getKookies();
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
Are you trying to set the cookies and read them back all within the same request cycle?
|
 |
naresh kavya
Greenhorn
Joined: Jul 15, 2006
Posts: 5
|
|
no i am using cookies in struts when the user enters in to page first time 2 cookies will be set in his browser memory for this i used the cookies with max age as 40000.(at the time of cookies setting i monitored the cookies age with getMaxAge().it is showing as 40000 only.)but when the user again visit the page later point of time my code is retrieving the cookies from his browsers memory .i monitored its maxage as -1.eventhough its max age is -1 application is showing that perticular users personalized data only.
|
 |
naresh kavya
Greenhorn
Joined: Jul 15, 2006
Posts: 5
|
|
no i am using cookies in struts when the user enters in to page first time 2 cookies will be set in his browser memory for this i used the cookies with max age as 40000.(at the time of cookies setting i monitored the cookies age with getMaxAge().it is showing as 40000 only.)but when the user again visit the page later point of time my code is retrieving the cookies from his browsers memory .i monitored its maxage as -1.eventhough its max age is -1 application is showing that perticular users personalized data only. i hope you understand the problem thank you
|
 |
 |
|
|
subject: about Cookies
|
|
|