HttpOnly attribute is used to preventing session leakage, since it does not allow the cookie to be accessed via a client-side script such as JavaScript. HttpOnly must be set to all session/sensitive cookies.
Reference Link - https://owasp.org/www-project-web-sec...