[Logo]
Forums Register Login
Cookies doubt
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
No, the browser will only serve cookies to the server from which they came.
So is it the browsers responsiblity to send the cookie assosciated with the domain iam accessing with the request...
Yes
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
 

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.
But if we want to access the cookie how to do about it..??
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
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 ]
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.
For particular domain, you can store more than a Cookie. This is the reason why? API has a return type as Cookie[] array.

HTH,
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 ]
Sometime your application might have the need to store multiple key value pairs of information.so multiple cookies from the same site is supported.
Hi,

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

Any suggestions!!!
I like tacos! And this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature


This thread has been viewed 1011 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 21, 2018 15:25:29.