aspose file tools
The moose likes Servlets and the fly likes Adding and retieveing values from Cookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Adding and retieveing values from Cookie" Watch "Adding and retieveing values from Cookie" New topic

Adding and retieveing values from Cookie

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

Hi every one.
I want to create a cookie object (from the Cookie class) and store the user information using this cookie (like JavaRanch)
but how to add values to this cookie (like username, password) and then retrieve it later ??
the Cookie constructor takes the name of the cookie and its contents (String object I think).
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12868
Are you really trying to program servlets without having the servlet API on hand? The cookie constructor takes a String name and a String value.
Cookies have a name and a single value, so you can either make separate cookies for name and for password, or come up with a way to combine name and password in a single String. If you do a setValue on a cookie, the new value replaces the old one.
jQuery in Action, 2nd edition
subject: Adding and retieveing values from Cookie