Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing data in cookies  RSS feed

 
sridhar lakka
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot in advance.
How can we store data in cookies.
i.e., I have search functionality where user can search for various things, If user searched for some f1, f2 in previous times then suppose if he is searching for third I need to show earlier searchs like f1 and f2. As we dont have any user specific data we should keep this data in some cookies.
Please help me.
And one more without user information how can we store data in data base, like i dont have any user id or any thing user specific and if he came back after some days how I can I show his/her previous data.

Regards,
Sree
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JavaDocs for HttpServletResponse for methods to set cookies.
For retrieval of cookie data see HttpServletRequest JavaDocs.
For the related Http standard see the RFC 2965.

Every Java programmer working with servlets should have the Javadocs on hand for questions like this.

Bill
 
Ray Johnson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can probably use a unique identifier (key value pair having a uniquely generated name) as part of your cookie string to identify the user...technically it is the machine/login that you are referring to. This might work until the user clears his cookies. I believe I did understand your requirements.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!