phanalist

E0058: Cookie Missing Secure or HttpOnly

In plain English: A cookie without Secure can be sent over plain HTTP. A cookie without HttpOnly can be read by JavaScript. Session and authentication cookies should set both flags.

Why it matters: Without Secure, a cookie can leak over an insecure connection. Without HttpOnly, a cross-site scripting bug can steal the cookie.

Bad

setcookie('session', $id);
setcookie('session', $id, ['secure' => true]);
session_set_cookie_params(['httponly' => true]);

Good

setcookie('session', $id, [
    'secure' => true,
    'httponly' => true,
    'samesite' => 'Lax',
]);

session_set_cookie_params([
    'secure' => true,
    'httponly' => true,
    'samesite' => 'Lax',
]);

Secure means the browser only sends the cookie over HTTPS. HttpOnly means JavaScript cannot read it. SameSite controls when the browser sends the cookie with cross-site requests; Lax is a common default.

What the rule checks

When it does not report

How to fix

Model limits

Configuration

E0058 has no configuration options and is enabled by default.