0

There is a webService in a server that my HTML code POSTs a form to it and receives an answer from the webService. but when the webService is called, it sends a cookie with name "ASP.NET_SessionId" (it's value is something like "bmbggmfm2rsi0rvspq5eiqrv"), can I retrieve this cookies value in my HTML code ?

Navid777
  • 3,591
  • 8
  • 41
  • 69
  • It seems to me you just need to read cookies in javascript. If so then can you read http://stackoverflow.com/questions/5639346/shortest-function-for-reading-a-cookie-in-javascript ? – Alexander Stepaniuk Dec 16 '12 at 16:09

1 Answers1

1

If I understand you right, you POST some data to a domain different to your page's origin, and want to read a cookie sent from that domain. This is not possible due to security restrictions.

Depending from your needs, there could be a workaround. For example, if you need some kind of session identifier, and this information is considered as legitimate to read, then great chances are that the webservice provides a special method to read the info.

Stan
  • 8,683
  • 9
  • 58
  • 102
  • yes, that's exactly my problem, so I can't have access to the cookies of another domain ? even with document.cookie ? – Navid777 Dec 17 '12 at 11:27
  • No, because the `document` in your page is originated at your site, not the webserice's one. So `document.cookie` contains cookie of your site. – Stan Dec 17 '12 at 12:13