Setting Cookie Secure Flag – ASP.NET

Method #1 Setting Secure Property True

Create Cookie by setting secure property true:

HttpCookie cookie = new HttpCookie('name');
cookie.Secure = True;
cookie.Value = 'Value';

Method#2 Using web.config

Add the following codes to web.config

<system.web>
<httpCookies requireSSL="true" />
</system.web>

Reference

https://www.owasp.org/index.php/SecureFlag

1 reply
  1. Susann
    Susann says:

    Even when I set secure=True, FireFox’s debugging panel still shows “secure” as “false”.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply to Susann Cancel reply

Your email address will not be published. Required fields are marked *