Guides › Hosting, domain & email › Security & hacks

Cookie Flags: Secure, HttpOnly and SameSite Explained

Safer cookies.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Security and hacking

Cookie flags tell browsers how to protect cookies. Three matter most: Secure, HttpOnly and SameSite. They reduce theft and cross-site attacks.

1Secure2HttpOnly3SameSite=Lax4SameSite=Strict and None5Set them in PHP6Check in the browser7WordPressFixed? Test the site. If not, get help.
The steps in order. Work down the list and stop when the problem is solved.

Step 1: Secure

Illustration for Step 1: Secure

The cookie is sent only over HTTPS. Set it on every cookie once your site uses HTTPS.

Step 2: HttpOnly

Illustration for Step 2: HttpOnly

JavaScript cannot read the cookie, which protects session cookies from cross-site scripting theft.

Step 3: SameSite=Lax

Illustration for Step 3: SameSite=Lax

The cookie is not sent with most cross-site requests. It is a good default for logins.

Step 4: SameSite=Strict and None

Illustration for Step 4: SameSite=Strict and None

Strict blocks all cross-site use. None allows it but must also be Secure.

Step 5: Set them in PHP

Illustration for Step 5: Set them in PHP

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

Step 6: Check in the browser

Illustration for Step 6: Check in the browser

Press F12, Application, Cookies and look at the flag columns.

Step 7: WordPress

Illustration for Step 7: WordPress

Most core cookies already use these. Check plugins that set their own.

Still stuck?

If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-22.