Using cookies in JSP
Posted on 2008-06-23
I've got a need to store user identity in a web application so that the user can "stay logged in" and not have to do so on each access to a site, and even if they don't elect to do that, to remember who the user is when browsing round the site once they have logged in. I'm guessing the way to do this is with cookies so I've been trying to play with them, but my IDE (Eclipse) is throwing up an error, saying it doesn't recognise a type called Cookie (cannot be resolved to a type, it actually says).
Now I've found out that Cookie is defined in javax.servlet.http.* but if I prepend with this, I get the same problem with javax.servlet. Now I guess this means I'm missing something, but what I'm missing and where to find it I don't know.
Further I've got no experience with Cookies at all so any *simple* pointers would be appreciated, including advice on whether my approach as detailed above is the right one to adopt here.