4

I'm having a (browser) cookie issue here.

I have a Sharepoint page (http://myServer:24628/sites/myApp/myDocumentLibrary/test.aspx). When the page is requested, I can see in the request headers (using firebug) that there's a ASP.NET_SessionId cookie.

Request headers:

Host: myServer:24628
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Cookie: ASP.NET_SessionId=2vhaxii0hxqeazii2sgw3q55; WSS_KeepSessionAuthenticated=24628
If-Modified-Since: Thu, 27 Oct 2011 15:41:15 GMT
Cache-Control: max-age=0

Response headers:

Cache-Control: private, max-age=0
Content-Length: 210604
Content-Type: text/html; charset=utf-8
Expires: Wed, 12 Oct 2011 15:41:24 GMT
Last-Modified: Thu, 27 Oct 2011 15:41:24 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 12.0.0.6421
X-AspNet-Version: 2.0.50727
Set-Cookie: WSS_KeepSessionAuthenticated=24628; path=/
http%3A%2F%2FmyServer%3A24628%2Fsites%2FmyApp%2FDiscovery=WorkspaceSiteName=UG9ydGFs&WorkspaceSiteUrl=aHR0cDovL3dlYmFwcDAxOjI0NjI4L3NpdGVzL251bnRpbw==&WorkspaceSiteTime=MjAxMS0xMC0yN1QxNTo0MTozMQ==; expires=Sat, 26-Nov-2011 16:41:31 GMT; path=/_vti_bin/Discovery.asmx
Date: Thu, 27 Oct 2011 15:41:31 GMT

After the page loads I make an asmx request (POST):

Request headers:

Host    myServer:24628
User-Agent  Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept  text/javascript, text/html, application/xml, text/xml, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection  keep-alive
X-Requested-With    XMLHttpRequest
X-Prototype-Version 1.7
Content-Type    application/json; charset=UTF-8
Referer http://myServer:24628/sites/myApp/myDocumentLibrary/test.aspx
Content-Length  42
Cookie  WSS_KeepSessionAuthenticated=24628

Right before making the asmx call, I alert the value of the 'ASP.NET_SessionId' cookie. It's there and it's value is correct.

In the notify.asmx call I need to retrieve the cookie value to be able to run some logic. This obviously fails.
What is going on here?

Ow yea,

Manu.

TweeZz
  • 4,779
  • 5
  • 39
  • 53
  • 6
    [Possible suspect](http://upload.wikimedia.org/wikipedia/en/5/5e/Cisforcookie.jpg). – Josh Darnell Oct 27 '11 at 16:00
  • 1
    @jadarnel27 you will able to put a smile on my face after 6 hours of being grumpy.. thx – TweeZz Oct 27 '11 at 16:08
  • @jadarnel27 - Ha! I was going to post the same! I've been beaten to answers before, but not cookie monster comments! – Curtis Oct 27 '11 at 16:10
  • 1
    @Curt Great minds! @ TweeZz You're welcome =) – Josh Darnell Oct 27 '11 at 16:19
  • Where is the javascript loaded from that makes the call? Is it coming from "myserver:24628" or some other domain? see http://stackoverflow.com/questions/2870371/why-jquery-ajax-not-sending-session-cookie – NotMe Oct 27 '11 at 17:18

3 Answers3

2

Your cookie isn't sent because the Host field is not the same on the two requests:

Host: webapp01:24628

Host myServer:24628

Community
  • 1
  • 1
Martin
  • 5,954
  • 5
  • 30
  • 46
  • that is just because I forgot to change "webapp01" manually before making the post.. my bad, sry – TweeZz Oct 27 '11 at 16:57
1

The javascript was indeed loaded from a different location. As Chris Lively suggested in a comment on my question.

TweeZz
  • 4,779
  • 5
  • 39
  • 53
0

Covering all bases, do you have [WebMethod(EnableSession = true)] ?

Is this only happening in IE? Have seen this with IE only, had to add a P3P header entry, but that was for cross-domain SSO solution.

rick schott
  • 21,012
  • 5
  • 52
  • 81
  • 2
    Why would this have to do anything with the WebMethod attribute? It seems its the browser not tranferring the cookie.. – TweeZz Oct 27 '11 at 16:38