This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes storing server side cookie at client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "storing server side cookie at client side" Watch "storing server side cookie at client side" New topic
Author

storing server side cookie at client side

Suresh Magi
Greenhorn

Joined: Apr 16, 2008
Posts: 19
Hi,

I was working on cookie and i had got this question for which i was not able to find the clue.

lets assume that we need to store a cookie at the client side using a javascript "document.cookie" so that it writes a cookie at the client side and this cookies will be there as long as we delete it and so when we say request.getCookies() we will get all the cookies stored at the client side whenever we open a new session.

But what if i want to add a cookie from the server side to client side. i.e at the server side i add a cookie using response.addCookie() and this will be there in the request as long as the session is valid / lives but i wanted to write this cookie into the client side and so this cookie will remain even after the session is closed and reopened

Thanks,
Suresh B
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The Cookie class has a method setMaxAge().

Guess what it does.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: storing server side cookie at client side