Two Laptop Bag*
The moose likes Servlets and the fly likes How to Check If Cookies are Enabled/Disabled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Check If Cookies are Enabled/Disabled " Watch "How to Check If Cookies are Enabled/Disabled " New topic
Author

How to Check If Cookies are Enabled/Disabled

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

Dont know if this is already asked. Searching did not help. I was trying to implement a piece of code which checked if the cookies were enabled or disabled on the client browser. If disabled i wanted to show an error. Could you give me some pointers on how to do so? I know how to do it via JavaScript.... but wanted to implement this on the server side. Thanks for the help in advance.
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

In the servlet use javax.servlet.http.Cookie to set/read a cookie.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You can try setting a cookie then try to read it back, and see if it's sent as part of the request.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

this discussion on stack overflow seems quite complete
http://stackoverflow.com/questions/531393/how-to-detect-if-cookies-are-disabled-is-it-possible
 
Consider Paul's rocket mass heater.
 
subject: How to Check If Cookies are Enabled/Disabled