开发者

ASP.NET Cookie not set when using https

开发者 https://www.devze.com 2023-01-10 02:17 出处:网络
I have an ASP.NET application which stores a \"Remember Me\" token as a cookie; it worked fine until I implemented SSL.

I have an ASP.NET application which stores a "Remember Me" token as a cookie; it worked fine until I implemented SSL.

Using FireCookies, I never see my cookie (named "_rmtoken") though ".ASPXAUTH", "ASP.NET_SessionId" and other cookies do show up. Here is the code I use to set the cookie:


public static void SetRememberMeCookie(HttpContext context, Guid token)
{
    DeleteRememberMeCookie(context);
    var loginCookie = new HttpCookie("_rmtoken")
    {
        Value = token.ToString(),
        Expires = DateTime.Today.AddMonths(1), 
        HttpOnly=false, 
        Secure = false
    };
    context.Response.Cookies.Add(loginCookie);开发者_如何学Python
}



Change this line from false to true

Secure = false

Msdn Reference - HttpCookie.Secure property


Simply try to set cookie's domain property for your cookies:

Response.Cookies["your_cookie_name"].Domain = "yourdomain.com";

... or check out this article to get more information.

0

精彩评论

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