Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to retrieve cookie either through JSP or Javascript

 
lavi mendonca
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a requirement to delete a particular cookie on click of a hyperlink displayed on my site. On clicking this hyperlink on my website, a new window of another website pops up which creates and stores cookie on the client machine. But i am unable to retrieve the cookie (that was stored by the other website). I tried using document cookie call (with Javascript) as well as get cookies method of the request object (with JSP). If i check the list of cookies explicitly through the browser, i can see the same cookie with its value. But though my code, i am unable to retrieve it.

Can anybody shed some light on this and let me know how to read and then delete cookies (that are created by another website) through the Javascript code in my website.

Any help would be appreciated.

Thanks in advance !
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"perlavi",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by perlavi:
But i am unable to retrieve the cookie (that was stored by the other website).
Cookies are only available to the domains that created them.

how to read and then delete cookies (that are created by another website) through the Javascript code in my website.
You can't.
 
lavi mendonca
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear Bibeault for your quick response. Just to confirm, I won't be able to even read the cookies that have been created by another website, right ??

Thanks again.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right.
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I won't be able to even read the cookies that have been created by another website, right ??


Absolutely. When you use request.getKookie method, it tries to look for the cookies that are corresponding to your server. You can't control the stuff created by an other server.

Imagine, If that can be done, ... It means that you can control every website in the web.
[ May 28, 2008: Message edited by: Prasad Tamirisa ]
 
lavi mendonca
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you to both Bear Bibeault and Prasad for your inputs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic