• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Retrieving Cookies

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic