• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving Cookies

 
padmanabh dongre
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am reading the cookies from the client machine to see whether , he has previously visited my site. currently i invoke a method request.getCookies() to get all the cookies and then loop thru them to find out whether the required cookie is there or not. Is there a method or a way to find out directly whether he has the cookies from my site. or everytime i have to loop thru all the cookies on his machine ( this takes time if he has lot of cookies).
Thanx
Padmanabh
 
Phil Hanna
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getCookies() returns only the cookies sent with this particular request, not every cookie on the user's machine.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...so if you (padmanabh) do not get any cookies when you call the method getCookies(), then there are not any that you previously sent.
Well, almost.
The servlet API allows you to sate
myCookie.setDomain("........");
That domain could be any domain. So theoretically you could send a cookie from a domain so that ANOTHER domain may read it. Unless you have Netscape 4.x (and I hope 6.x) where you can choose the option "Accept only cookies that get sent back to the originating server".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic