HttpOnly and Secure Flag
Last updated
Was this helpful?
Last updated
Was this helpful?
HttpOnly is a flag added to cookies that tell the browser not to display the cookie through client-side scripts (document.cookie and others). The agenda behind HttpOnly is not to spill out cookies when an XSS flaw exists, as a hacker might be able to run their script but the fundamental benefit of having an XSS vulnerability is lost.
Secure flag is an option that can be set by the application server when sending a new cookie to the user within an HTTP Response. The purpose of the secure flag is to prevent cookies from being observed by unauthorized parties due to the transmission of a the cookie in clear text.
we can use the browser extension for view the cookies and flags are set or not.
Use extension to view the cookies.
Use extension to view the cookies.
Install the extension in your browser.
Go to the site and open the cookie extension.
You can see the each cookie and the flag is set or not
We can access to the php.ini file, add below code in end of the file to make the HttpOnly and Secure flag.
We can add the ini_set
function in top of the each php page.
We can also use header
function to mark the cookie as HttpOnly and Secure flag. We have to add in top of the each php page.
We have to access the web.config file and add the below code to make the HttpOnly and Secure flag.
We have to insert the below code in the program.