Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Cookie not set when using https

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);
}


like image 606
Keith Avatar asked Aug 06 '26 16:08

Keith


1 Answers

Change this line from false to true

Secure = false

Msdn Reference - HttpCookie.Secure property

like image 67
heads5150 Avatar answered Aug 09 '26 19:08

heads5150