wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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

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.

So much trouble in the world -- Bob Marley
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

this discussion on stack overflow seems quite complete
Don't get me started about those stupid light bulbs.
subject: How to Check If Cookies are Enabled/Disabled
Similar Threads
Determining if cookies are disabled via Servlet/JSP
Cookie Detection
how to know the Status of the cookies
How to hide the jsessionid id in my address bar in servlet programming
How to check if cookie is enabled or not