ASPx set Cookie Domain
I have a code as follows开发者_运维问答:
this.Response.Cookies.Add(new HttpCookie("COOKIENAME",'test'));
I want to add the domain ".test.com" for this cookie. How do I do so? I tried the standard:
this.Response.Cookies["COOKIENAME"].Domain = ".test.co.uk";
But the cookie is not being set for the whole domain. Any suggestions?
The following is not working either:
HttpCookie MyCookie = new HttpCookie("COOKIENAME");
MyCookie.Value = 'test';
MyCookie.Domain = ".test.co.uk";
this.Response.Cookies.Add(MyCookie);
I don't think you need the ".", so just MyCookie.Domain = "test.co.uk";
.
I think you should use the Cookie Path
property to define the domain of the cookie
精彩评论