Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Cookies doubt

 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In our servlet code..we say request.getKookies() which returns cookies array.

My doubt is suppose i have a tomcat server in machine A

and the client accesses the site from machine B which already has cookies set from many sites...

Now when the user accesses the site and the code above gets executed,
will the cookie array contain all the cookies residing in the clients browser??

Regards
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, the browser will only serve cookies to the server from which they came.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is it the browsers responsiblity to send the cookie assosciated with the domain iam accessing with the request...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ben!!


Suppose I have a web application(say site A) such that it should check from request of the client whether a cookie of site B exists and if exists show sometthing ..and if doesnt exists the show soemthing else....

How can we read the cookie of site B when the client requests on the site A.

Regards
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by A Kumar:
Thanks Ben!!


Suppose I have a web application(say site A) such that it should check from request of the client whether a cookie of site B exists and if exists show sometthing ..and if doesnt exists the show soemthing else....

How can we read the cookie of site B when the client requests on the site A.

Regards



I think, it is not possible as it's a matter of security.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But if we want to access the cookie how to do about it..??
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Web site can retrieve only the information that it has placed on your machine. It cannot retrieve information from other cookie files, nor any other information from your machine.

more info on http://computer.howstuffworks.com/cookie1.htm

hope this helps
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

From what i have read is that the a site can read only the cookie set by the same domain,
then why is that the request.getKookies() returns an array of cookies..

and the user has to iterate to get the required cookie...

Can't it directly give you the cookie...assosciated with the doamin..

or am i missing something ???

Regards
[ November 16, 2006: Message edited by: A Kumar ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set mulitple cookies from an application.

You can not, however, read cookies set by other applications.
Think of the security problems that would exist if you could.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For particular domain, you can store more than a Cookie. This is the reason why? API has a return type as Cookie[] array.

HTH,
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So a domain can set multiple cookies.. but whats the purpose for such a technique....to be used...


Just read that a browser is expected to support 20 cookies for each webserver,300 cookies in total and may limit cookie size to 4 Kb each.
[ November 16, 2006: Message edited by: A Kumar ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometime your application might have the need to store multiple key value pairs of information.so multiple cookies from the same site is supported.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I just found this URL...
Cross Domain Cookie Provider

Any suggestions!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic