开发者

ASPx set Cookie Domain

开发者 https://www.devze.com 2023-02-18 14:05 出处:网络
I have a code as follows开发者_运维问答: this.Response.Cookies.Add(new HttpCookie(\"COOKIENAME\",\'test\'));

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

精彩评论

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