File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Cookie Detection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookie Detection" Watch "Cookie Detection" New topic

Cookie Detection

Sam Furtado
Ranch Hand

Joined: Jul 16, 2002
Posts: 45
Hi Guys !!!
I wanted to create a Cookie holding user authentication info and place it on the client side and furthur pick it up the next time the user tries to access the site. In this case how should it be detected whether the user has Cookies enabled / disabled in which case the user could be furthur prompted to enable cookies in his browser settings. Also, do all browser including netscape support cookies.
Pls suggest.

Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

The way you find out if cookies are disabled is by sending one out and seeing if it comes back.
Unless you're on an intranet and have clout with management, DON'T expect you can force users to turn on cookies. In the wider world, some institutions even force users to turn OFF cookies!
Cookies are OK for "preference"-type info where nothing really gets hurt if the cookie isn't accepted, but for maintaining a session, use the URL-rewriting methods and store the info on the server side with a session. That will ensure that the session is tracked, either by cookies, or of that's not possible by appending session info onto the URL that the user returns.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Cookie Detection
jQuery in Action, 3rd edition