[PR #7256] [MERGED] fix(multi-session): prevent duplicate cookies when same user signs in multiple times #15426

Closed
opened 2026-04-13 10:01:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7256
Author: @Paola3stefania
Created: 1/11/2026
Status: Merged
Merged: 1/27/2026
Merged by: @himself65

Base: canaryHead: fix/multi-session-duplicate-cookies


📝 Commits (10+)

  • f2226df feat: add refecth to all clients
  • e6b058d Merge branch 'canary' into fix/add-refetch-to-all-clients
  • e734be2 make lint happy
  • 27599e3 fix: multi sesion
  • 993498e fix
  • d80abe7 Merge branch 'canary' into fix/multi-session-duplicate-cookies
  • 1a4dc9d Merge branch 'canary' into fix/multi-session-duplicate-cookies
  • 89967e0 Merge branch 'canary' into fix/multi-session-duplicate-cookies
  • 6ef595f fix tests and types
  • c93dd33 chore: lint fix

📊 Changes

2 files changed (+93 additions, -14 deletions)

View changed files

📝 packages/better-auth/src/plugins/multi-session/index.ts (+33 -14)
📝 packages/better-auth/src/plugins/multi-session/multi-session.test.ts (+60 -0)

📄 Description

Closes https://github.com/better-auth/better-auth/issues/4490 and https://github.com/better-auth/better-auth/issues/6184


Summary by cubic

Fixes duplicate multi-session cookies when the same user signs in multiple times on the same device. Old session cookies and records are removed, and max session limits are enforced; also adds refetch(queryParams) to useSession across clients.

  • Bug Fixes

    • Delete existing multi-session cookies and sessions for the same user on sign-in, then set a single new cookie.
    • Recalculate and enforce maximumSessions after cleanup; added tests to verify cookie deletion and single-session state.
  • New Features

    • Added refetch(queryParams) to useSession across clients with updated typings and tests.

Written for commit c93dd33bf1. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7256 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 1/11/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/multi-session-duplicate-cookies` --- ### 📝 Commits (10+) - [`f2226df`](https://github.com/better-auth/better-auth/commit/f2226df19c152ecb94d2cc5dfdcce2b3d77be5ab) feat: add refecth to all clients - [`e6b058d`](https://github.com/better-auth/better-auth/commit/e6b058d97f430608b1c4e415d39737f11bebc1ca) Merge branch 'canary' into fix/add-refetch-to-all-clients - [`e734be2`](https://github.com/better-auth/better-auth/commit/e734be20542d7bac92cc7f3229e4541bce5a90db) make lint happy - [`27599e3`](https://github.com/better-auth/better-auth/commit/27599e35e3d7cac0caad1489ee801deb7936bfa6) fix: multi sesion - [`993498e`](https://github.com/better-auth/better-auth/commit/993498e34b784a8aee2d01bae0125df4d2645ce8) fix - [`d80abe7`](https://github.com/better-auth/better-auth/commit/d80abe73f871e594a602eaa29f00b612ea78dfd6) Merge branch 'canary' into fix/multi-session-duplicate-cookies - [`1a4dc9d`](https://github.com/better-auth/better-auth/commit/1a4dc9d3a1f90527062857321a7687e633a119d7) Merge branch 'canary' into fix/multi-session-duplicate-cookies - [`89967e0`](https://github.com/better-auth/better-auth/commit/89967e030badede4b43fff13bb2288ff7a71d928) Merge branch 'canary' into fix/multi-session-duplicate-cookies - [`6ef595f`](https://github.com/better-auth/better-auth/commit/6ef595f0807d4bc63028d8b7da97b1cc761e71d8) fix tests and types - [`c93dd33`](https://github.com/better-auth/better-auth/commit/c93dd33bf1d9678dcfbeab3421438e1d1de95f15) chore: lint fix ### 📊 Changes **2 files changed** (+93 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/multi-session/index.ts` (+33 -14) 📝 `packages/better-auth/src/plugins/multi-session/multi-session.test.ts` (+60 -0) </details> ### 📄 Description Closes https://github.com/better-auth/better-auth/issues/4490 and https://github.com/better-auth/better-auth/issues/6184 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes duplicate multi-session cookies when the same user signs in multiple times on the same device. Old session cookies and records are removed, and max session limits are enforced; also adds refetch(queryParams) to useSession across clients. - **Bug Fixes** - Delete existing multi-session cookies and sessions for the same user on sign-in, then set a single new cookie. - Recalculate and enforce maximumSessions after cleanup; added tests to verify cookie deletion and single-session state. - **New Features** - Added refetch(queryParams) to useSession across clients with updated typings and tests. <sup>Written for commit c93dd33bf1d9678dcfbeab3421438e1d1de95f15. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 10:01:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#15426