• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookie question

 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

I have a question regarding cookies.

Lets say I signup with Website_A and it sets a "username" cookie in my machine, so it can print 'hello praveen' the next time I visit that page.

Now I log into Website_B and it looks for a "username" cookie to say 'hello praveen' on the welcome screen. Now since this is the first time im visiting the page will it NOT print 'hello praveen' OR will it pick the cookie set earlier by a difference application which incidentally has the same name ?

Im under the impression that all cookies(from all webpages) are saved in a particular place in the client machine. Since they have only a name and a value how can it be related to a particular servlet/webpp etc. ?

Please advice
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put simply, the browser is not supposed to send all cookies to all web-pages. Only the cookies originating from the domain of the server in question should be enclosed with the request.
This behaviour can be verified by surfing around for a while and then writing a servlet or JSP that retrieves and displays the cookies in a request. Compare the cookies displayed by your servlet/JSP with the cookies your browser tell you are present on your machine. Allowing sites to set cookies in your browser is a prerequisite.
[ June 22, 2007: Message edited by: Navi Nirsak ]
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Navi.
 
madhuri rajan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This question might not fit well here. But sorry, could not find a more apt thread. Coming to the question what can be the data types of the (key, value) pair that goes into the cookie constructor? I know that the key can only be a string ... but can the value be of any data type including any non-primitive ones?

Thanks,
Madhuri
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic