Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Subdomain cookie not shared, user logged out: how to fix it

CNV-364Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A cookie is a small piece of data the browser stores and sends back to your site. If the server sets a cookie without a Domain attribute, it is a *host-only* cookie. The browser sends it only to the exact hostname that set it.

Why it costs you leads or sales

Where the session is lost
  1. Ad clickLands on www.example.com
  2. Log inSession cookie set for www only
  3. Move to app. subdomainCookie not sent, user looks logged out
  4. Checkout or bookingVisitor must log in again or leaves

The visitor logs in on www, then moves to a subdomain that cannot see the cookie.

Logged out after the hop

The page on the second subdomain loads, but it cannot read the session and shows a login wall.

How to check if your site has it

Inspect the cookie in your browser
  1. Log in on the first subdomain

    Use a private window so old cookies do not interfere.

  2. Open developer toolsChrome

    In Chrome, press F12, go to Application, then Cookies, and select your site.

  3. Read the Domain column

    If it shows www.example.com (no leading dot), the cookie is host-only. If it shows .example.com, subdomains can use it.

  4. Click through to the other subdomain

    Follow a real link, such as Buy now or My account. Check whether you are still logged in and whether the cart is intact.

  5. Compare cookies on both hosts

    Note which session, cart, visitor ID and consent cookies exist on one host but not the other.

How to fix it

Share the cookie across subdomains
  1. Set the cookie domain in wp-config.php

    Add define('COOKIEDOMAIN', '.example.com'); above the line that says to stop editing. Everyone is logged out once, then the login cookie covers subdomains. On multisite, check your existing COOKIE_DOMAIN setting first.

  2. Check plugins

    Cart and membership plugins may set their own cookies. Look in their settings for a cookie domain option.

Set-Cookie header that works across subdomainstext
Set-Cookie: session=abc123; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Lax
Express (Node.js) session cookie examplejavascript
app.use(session({
  secret: process.env.SESSION_SECRET,
  cookie: {
    domain: '.example.com',
    secure: true,
    httpOnly: true,
    sameSite: 'lax'
  }
}));
Cookie scope

Host-only cookie

  • No Domain attribute
  • Sent only to www.example.com
  • app. subdomain shows a login wall

Parent-domain cookie

  • Domain=example.com
  • Sent to www, app and checkout
  • Visitor stays logged in

How to confirm it's fixed

Confirmation checks
  • Log out fully, clear cookies, and log in again in a private window
  • In Application, then Cookies, the session cookie shows a Domain with a leading dot (.example.com)
  • Click through to every subdomain in the journey and stay logged in
  • The cart contents match after the hop
  • Test in Chrome, Safari and Firefox, and on mobile
  • Analytics shows one session and the original campaign source across both hosts

How to prevent it happening again

Toggle the cookie scopeInteractive
Cookie set for one host only

Host-only cookie

Leads or data lost

The visitor moves to the second subdomain and is shown a login screen or an empty cart. Many leave.

Switch the cause on to see what the visitor sees after crossing subdomains.

How FunnelGuard handles this

Questions people ask

Why does my user get logged out when they go from www to a subdomain?

The session cookie was probably set without a Domain attribute, so it is host-only. The browser then sends it only to the exact hostname that created it. Set Domain to your parent domain, such as .example.com, to share it.

How do I share cookies between subdomains?

Set the cookie's Domain attribute to the parent domain, for example Domain=example.com, when the cookie is created. Every subdomain must also read the same session store or token. Test the journey after the change.

Can I share cookies between two different domains?

No. Cookies only work within one registrable domain and its subdomains. For different domains you need another approach, such as passing a signed token in the URL or using a shared login service.

Does a leading dot in the cookie domain matter?

In current browsers, Domain=example.com and Domain=.example.com both apply to subdomains. DevTools often shows the leading dot for cookies that are shared. A host-only cookie shows the exact hostname with no dot.

Why is my cart empty on the checkout subdomain?

The cart is often stored in a cookie or a session tied to the first hostname. If the checkout subdomain cannot read that cookie, it starts a new empty cart. Share the cookie domain and the session store between both hosts.

Can SameSite settings cause logouts between subdomains?

Subdomains of the same site count as same-site, so SameSite=Lax rarely blocks them. Problems are more likely with embedded pages or different domains. Still check Secure, Path and cookie size if the Domain looks right.

Does FunnelGuard detect cookie domain problems?

No. FunnelGuard does not check cookie domains yet; it is a possible future check. It does run your real journeys and reports a failed step with a screenshot, which can show the effect but not the cause.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: logged_in_element on a journey across subdomains (logged_out); cookie domain not inspected.

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.