开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜