Question

I have 2 identical web applications on my machine running in different application pools. They have the host address as below:

cookie1.cookies.prt

cookie2.cookies.prt

Before I perform a response.redirect from cookie1.cookies.prt to cookie2.cookie.prt I add a cookie to response as such:

        Response.Cookies.Add(new HttpCookie(
            "CookieTest", "This is to test the cookie domain")
        {
            Domain = ".cookies.prt"
        }
        );

Now I can see in fiddler that the response from cookie1.cookies.prt does contain the cookie. But the request from cookie2.cookies.prt does not contain the cookie. I thought as long as they in the same domain (.cookies.prt) this should work. Am I missing something?

Was it helpful?

Solution

Figured it out. Just needed to added Path to the cookie creation. Or else the cookie is set to cookieX.cookies.prt/default.aspx.

        Response.Cookies.Add(new HttpCookie(
            "CookieTest", "This is to test the cookie domain")
        {
            Domain = ".cookies.prt",
            Path = "/"
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top