Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Cookies without Secure, HttpOnly or SameSite: how to fix

OPS-175Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A cookie is a small piece of data your site stores in a visitor's browser. Three optional attributes control how safely it behaves.

What each cookie attribute does
AttributeWhat it doesRisk if missing
SecureBrowser only sends the cookie over HTTPSCookie can travel over plain HTTP and be intercepted
HttpOnlyJavaScript cannot read the cookieAn injected script (XSS) can steal the session
SameSiteLimits sending the cookie on cross-site requests (Lax, Strict or None)Easier cross-site request forgery (CSRF) attacks

The flags matter most for session, login, cart and admin cookies. Marketing cookies such as _ga or _fbp are meant to be read by scripts, so they will not have HttpOnly. That is normal.

Why it costs you leads or sales

A stolen session cookie can let someone act as a logged-in customer or admin. That can mean hijacked accounts, defaced pages, redirected forms or injected scripts that skim leads. Security scanners and some enterprise buyers also flag missing flags during reviews, which can slow a deal. The impact is medium: it rarely breaks a funnel by itself, but it makes other attacks more damaging.

How a weak cookie leads to lost leads
  1. Visitor logs inSession cookie is set without flags
  2. Script injectedVia XSS or a compromised third-party tag
  3. Cookie readNo HttpOnly, so JavaScript can access it
  4. Session hijackedAttacker acts as the user or admin

A script injected through another flaw reads a cookie that lacks HttpOnly.

How to check if your site has it

Inspect your cookies in the browser
  1. Open developer tools

    In Chrome or Edge press F12, then open the Application tab. In Firefox open the Storage tab.

  2. Select Cookies for your domain

    Expand Cookies in the left panel and click your site address.

  3. Read the flag columns

    Look at the HttpOnly, Secure and SameSite columns. Empty cells mean the attribute is not set.

  4. Check the raw header

    Open the Network tab, reload, click the first document request and look for Set-Cookie in Response Headers.

  5. Test while logged in

    Repeat after logging in, because session cookies are often only set then.

Check Set-Cookie headers from the command linebash
curl -sI https://www.example.com/ | grep -i '^set-cookie'

How to fix it

Start with cookies that identify a user: session, login, cart and CSRF tokens. Use Secure and HttpOnly on them, and SameSite=Lax unless you have a reason for something else. Note that SameSite=None only works together with Secure.

Set the flags on your platform
  1. Force HTTPS first

    Make sure Settings > General uses https:// addresses. WordPress marks its login cookies Secure automatically on HTTPS.

  2. Set flags for PHP sessions

    If a plugin or theme uses PHP sessions, add the ini settings shown in the Custom code tab to php.ini or .user.ini.

  3. Update or replace the offender

    If a specific plugin sets an unsafe cookie, update it or ask its developer. Check the plugin's settings for a cookie security option.

A correct Set-Cookie headertext
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
PHP: secure session cookies (before session_start)php
<?php
session_set_cookie_params([
  'lifetime' => 0,
  'path' => '/',
  'secure' => true,
  'httponly' => true,
  'samesite' => 'Lax',
]);
session_start();
JavaScript: set a cookie with safe attributesjavascript
document.cookie = 'pref=1; Path=/; Max-Age=31536000; Secure; SameSite=Lax';
Session cookie before and after

Before

  • Set-Cookie: session=abc123; Path=/
  • Readable by any script on the page
  • Can be sent over HTTP

After

  • Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
  • Hidden from JavaScript
  • Sent over HTTPS only

How to confirm it's fixed

Confirmation checklist
  • Clear cookies, reload and log in again
  • Application tab shows Secure and HttpOnly ticked on session and login cookies
  • SameSite shows Lax (or None with Secure where cross-site use is needed)
  • Login, cart and form submission still work end to end
  • Arriving from an ad or email link keeps the visitor logged in or the cart intact
  • A re-run of your security scanner no longer lists the cookie

How to prevent it happening again

Prevention habits
  • Set cookie defaults in one place, such as your framework or server config
  • Review cookies after installing a new plugin, app or embed
  • Run a header and cookie scan after each major release
  • Keep CMS core and plugins updated (see the related issues on outdated software)
  • Avoid storing sensitive values in JavaScript-set cookies

How FunnelGuard handles this

FunnelGuard does not check cookie flags today. It is a possible future check. FunnelGuard is a synthetic monitoring service: a robot visitor runs your real journeys, such as lead forms and checkouts, and checks each step, the tracking hits sent to ad and analytics platforms, and whether test leads arrive.

That is relevant nearby. If a cookie change such as SameSite=Strict or a broken HTTPS redirect stops a login, cart or form from working, a scheduled journey check can show the funnel failing at that step. It will not tell you the flags are missing.

Frequently asked questions

Questions people ask

Why is my cookie missing the Secure flag?

The server or script that sets the cookie did not include the Secure attribute, or your site is still partly on HTTP. Add Secure to the Set-Cookie header or session settings and make sure all pages redirect to HTTPS.

What does HttpOnly do on a cookie?

HttpOnly stops JavaScript from reading the cookie. If an attacker injects a script into your page, they cannot steal an HttpOnly session cookie that way.

Which SameSite value should I use?

Use Lax for most sites. It blocks the cookie on most cross-site requests but still works when someone clicks a link to your site. Use None only when you need cross-site use, and it must be paired with Secure.

Do analytics cookies like _ga need HttpOnly?

No. Analytics scripts must read those cookies, so HttpOnly would break them. Focus the flags on session, login and cart cookies.

Can I change cookie flags on Shopify, Wix or Squarespace?

Not for the cookies the platform sets itself. You can only control cookies written by your own custom code or apps, where you can add Secure and SameSite.

Will adding SameSite break my tracking or login?

Lax rarely does. Strict can log visitors out when they arrive from an ad or email, and None without Secure is rejected by browsers. Test your login, cart and form after any change.

Does FunnelGuard check cookie flags?

No, not yet. It is a possible future check. FunnelGuard does run your real journeys on a schedule, so a cookie change that breaks a login or form would show up as a failing step.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: site safety (Stage 26, daily): session-like cookies without Secure / HttpOnly on the home page.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.