The HttpOnly attribute when set to true protects the cookie value from being accessed by client side JavaScript such as reading the document.cookie values. By enabling this protection, a website that is vulnerable to Cross-Site Scripting (XSS) will be able to block malicious scripts from accessing the cookie value from JavaScript.
1// Noncompliant: http-only flag set to false
2session_set_cookie_params($lifetime, $path, $domain, true, false);1// Compliant: http-only flag set to true
2session_set_cookie_params($lifetime, $path, $domain, true, true);