Secure cookie with HttpOnly and Secure in Apache Ubuntu

 This is a new security feature introduced by Microsoft in IE 6 SP1 to mitigate the possibility of a successful Cross-Site scripting attack by not allowing cookies with the HTTP only attribute to be accessed via client-side scripts.

We can mitigate most common XSS attacks in our web application using HttpOnly and Secure flag with cookie.

Implementation Procedure in Apache2

  • Ensure that mod_headers.so are enabled in Apache HTTP server
  • Add below line in httpd.conf 
          Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
  • Restart Apache HTTP server to test ( sudo systemctl restart apache2 )

Note: You can check either leverage the browser’s inbuilt developer tools to check the response header or use an online tool.

Comments

Popular posts from this blog

Creating Protected routes in ReactJS

Redirect http to https in codeigniter