Cookies carry session IDs and authentication tokens. If not protected, attackers can steal them through insecure channels or client-side scripts. A stolen cookie lets an attacker impersonate a customer or even an admin.
The Secure flag makes sure cookies are only sent over HTTPS.
The HttpOnly flag blocks JavaScript from reading cookies, reducing XSS impact.
The SameSite flag helps mitigate CSRF by controlling cross-site cookie usage.
Together, these flags provide strong protection for session handling.
# Open browser dev tools → Application → Storage → Cookies
# Check session cookies like PHPSESSID or frontend
# Expected: Secure; HttpOnly; SameSite=Lax (or Strict)
curl -I https://yourstore.com | grep -i set-cookie
# Should show Secure and HttpOnly flags
Stores → Configuration → General → Web → Default Cookie Settings
- Use HTTP Only: Yes
- Cookie Secure: Yes
HttpOnly and SameSite when setting cookies.Set-Cookie: PHPSESSID=abcd1234; path=/; domain=mystore.com
# Missing Secure, HttpOnly, SameSite
Set-Cookie: PHPSESSID=abcd1234; path=/; domain=mystore.com; Secure; HttpOnly; SameSite=Lax