File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Storing more then 20 cookies from same URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Storing more then 20 cookies from same URL" Watch "Storing more then 20 cookies from same URL" New topic
Author

Storing more then 20 cookies from same URL

Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
Hi

I am making a project in which i have around 30 fields and i want to store all of them in cookie so that when the user logged in again then all the fields get pre - populated, but the problem is that JSP allow only 20 cookies to set from one URL that is i am only able to create 20 cookies and rest with 10.

Please tell me that how to store multiple cookies that is more then 20 and can we store more then one value in one cookie.

Like now we use -:

String NonUSCookiesCountryString = country;
Cookie NonUS = new Cookie ("NonUS",NonUSCookiesString);
NonUS.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(NonUS);

Like now we have "NonUS" as a cokkie and have only one value in that , can we put more then on value in same cookie.

Please help me out.

Thanks
Regards
Gaurav
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
can we store more then one value in one cookie.

Sure but you are going to have to provide your own methods for creating and parsing the cookie string. According the RFC 2109, browsers should allow at least 4096 characters per cookie so you have lots of room to encode your values.
Bill
Gaurav Chhabras
Ranch Hand

Joined: Sep 21, 2005
Posts: 126
Thanks for the reply

as i used "-" as delimeter and break it through StringTokenizer but when i put the values of phone like .. 123-456-789, then it will create error because when StringTokenizer will break it then it will consider only "123" in one variable and rest of the part not being considered, thsts the problem.

Please help

Thanks
Regards
Gaurav
Sunny Kumar
Ranch Hand

Joined: Oct 27, 2005
Posts: 57
Take separate cookies for numbers and strings.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Have you thought about using a unique identifier as the cookie and then storing the fields and values in a database, using the udentifier as the key. When the user revisits the page use that identifier to acces the DB and retrieve/repopulate the fields.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing more then 20 cookies from same URL