This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide 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

How to Check If Cookies are Enabled/Disabled

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
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
I agree. Here's the link:
subject: How to Check If Cookies are Enabled/Disabled
It's not a secret anymore!