Skip to content

fix: Support multiple workos-has-session cookies - #137

Merged
cmatheson merged 1 commit into
mainfrom
read-multiple-has-session-cookies
Sep 17, 2026
Merged

cmatheson merged 1 commit into
mainfrom
read-multiple-has-session-cookies

Conversation

@cmatheson

@cmatheson cmatheson commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Imagine a setup with multiple environments at varying levels of nesting in a domain:

  • environment_1 has auth domain auth.foo-corp.com
  • environment_2 has auth domain internal.auth.foo-corp.com

If a user logs in to apps at in both environments, they will end up with multiple workos-has-session cookies. authkit-js used to only look at the first cookie (effectively allowing one environment to shadow the other).

This lets authkit-js read from every cookie the browser sends.

Imagine a setup with multiple environments at varying levels of nesting
in a domain:

* environment_1 has auth domain `auth.foo-corp.com`
* environment_2 has auth domain `internal.auth.foo-corp.com`

If a user logs in to apps at in both environments, they will end up with
multiple `workos-has-session` cookies. authkit-js used to only look at
the first cookie (effectively allowing one environment to shadow the
other).

This lets authkit-js read from every cookie the browser sends.
@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no actionable correctness, security, or repository-rule violations identified.

Summary

This PR updates browser session detection to inspect every workos-has-session cookie rather than only the first, preventing an overlapping cookie from hiding the session marker for the current WorkOS client.

  • Iterates all same-named cookies and succeeds when any value contains the current client ID.
  • Preserves support for the legacy "1" session marker.
  • Adds an initialization test covering two overlapping cookies where the relevant cookie appears second.

Reviews (1) · Last reviewed commit: "Support multiple `workos-has-session` co..."

@cmatheson cmatheson changed the title Support multiple workos-has-session cookies fix: Support multiple workos-has-session cookies Sep 17, 2026
@cmatheson
cmatheson merged commit 9d7530d into main Sep 17, 2026
5 of 6 checks passed
@cmatheson
cmatheson deleted the read-multiple-has-session-cookies branch September 17, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants