Two Laptop Bag*
The moose likes Servlets and the fly likes request.getCookies(); is not returning all the cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "request.getCookies(); is not returning all the cookies" Watch "request.getCookies(); is not returning all the cookies" New topic

request.getCookies(); is not returning all the cookies

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi All,
I have a strange problem. I try to get all the cookies by the following code

But its returning only one cookie and that is of JSessionId. I have confirmed that the cookie exists on the client side but somehow the function is not getting it. BTW at first the code worked fine for me but then later on it stopped working. Any ideas on this.

Thanks in advance.

Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60785

Are the cookies for the same domain within which the servlet is executing?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

Sometimes browsers have intelligence to block cookies, as it cannot distinguish between safe and unsafe ones. See if your browser has the option to turn ON to accept cookies.

Not many get the right opportunity !
It is sorta covered in the JavaRanch Style Guide.
subject: request.getCookies(); is not returning all the cookies
Similar Threads
Not able to set cookies
getCookie(FacesContext context, String name) function is not woring in tomcat 6.0.
response.addCookie is not working