-2

Is it possible to read cross domain cookie in C#? if possible how can i read the cookie, the cookie set in one domain like "dev-001" and get a cookie in another domain "localhost"

i used

Request.Cookies["userInfo"].Values 

it shows a null value.

Is there any possibilities.because it's our requirement. all the information are available in cookie. but I can't read it

sathish kumar
  • 25
  • 1
  • 6
  • 2
    This would be a hish security flaw, as most web site store authentication data in cookies. Can you explain what you are trying to do at a higher level ? – Steve B Feb 02 '12 at 09:11
  • Read up on this concept here: http://en.wikipedia.org/wiki/Same_origin_policy – Candide Feb 02 '12 at 09:13
  • possible duplicate of [cross domain cookies](http://stackoverflow.com/questions/1084114/cross-domain-cookies) – Emond Feb 02 '12 at 09:14

4 Answers4

5

No, that's not possible. Cookies cannot be shared cross domain. That would be a huge security flaw.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • i had dropped a cookie on user machine , and user wcf serive to retrieve info from website through which i had dropped the cookie , but i cannot read that dropped cookie in my wcf service , please help – Rizwan Patel Dec 23 '12 at 08:15
0

However you can allow all subdomains to have access if you set the domain to ".your_domain.com". A weird solution would be to redirect your user to one of the domain to get the cookie content, as bit like a webservice kind of thing but I wouldn't recommend that at all!

If you really need to store data about your user across multiple platforms, why not storing in a database?

John
  • 9
  • 1
0

Reading cookies from another domain in not possible. While there would be serious security implications if you could, the pragmatic reason is that the browser never sends cookies from other domains when it makes a request. So the information isn't available.

Sam Greenhalgh
  • 5,952
  • 21
  • 37
  • i had dropped a cookie on user machine , and user wcf serive to retrieve info from website through which i had dropped the cookie , but i cannot read that dropped cookie in my wcf service , please help – Rizwan Patel Dec 23 '12 at 08:17
0

From your brief description, you need to find a better way of performing the task at hand. Cookies cannot be shared across domain.

However, a third party can be introduced into the mix which allows sharing of data (albeit through a much more elaborate mechanism) though it is possible to disable third party cookies.

Cross-domain user tracking without 3rd party cookies?

Community
  • 1
  • 1
Tim M.
  • 53,671
  • 14
  • 120
  • 163