[PR #7412] [CLOSED] feat(multi-session): add support for custom session ID logic #7294

Closed
opened 2026-03-13 13:31:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7412
Author: @Lookwe69
Created: 1/16/2026
Status: Closed

Base: canaryHead: feat/multi-session-uniq-option


📝 Commits (2)

  • 1bc60df feat(multi-session): add support for custom session ID logic
  • 197bf5d fix(multi-session): sort imports

📊 Changes

2 files changed (+95 additions, -10 deletions)

View changed files

📝 packages/better-auth/src/plugins/multi-session/index.ts (+16 -10)
📝 packages/better-auth/src/plugins/multi-session/multi-session.test.ts (+79 -0)

📄 Description

This PR improves how sessions are listed and managed in the multiSession plugin. It introduces a configurable way to identify unique sessions and ensures that the returned data is properly de-duplicated.

Key Changes

  • Unique Session Logic: Added getUniqSessionId to MultiSessionConfig. This allows developers to define how sessions are grouped (e.g., by user.id to show one entry per account, or by session.token to show every active tab/device).

Summary by cubic

Adds configurable unique session logic to the multiSession plugin to control how device sessions are grouped and de-duplicated. Default groups by user.id; you can override to show per-device or per-tab sessions.

  • New Features
    • Added MultiSessionConfig.getUniqSessionId(data: { session, user }) => string (default: user.id).
    • listDeviceSessions now de-duplicates using getUniqSessionId.
    • Tests cover default grouping and custom token-based grouping.

Written for commit 197bf5d0ba. 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/7412 **Author:** [@Lookwe69](https://github.com/Lookwe69) **Created:** 1/16/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/multi-session-uniq-option` --- ### 📝 Commits (2) - [`1bc60df`](https://github.com/better-auth/better-auth/commit/1bc60dfd2be13ca9408df27fc2161e8c5b16c3f3) feat(multi-session): add support for custom session ID logic - [`197bf5d`](https://github.com/better-auth/better-auth/commit/197bf5d0ba32da904ba1ad32d36e4f3dfd9a7cc2) fix(multi-session): sort imports ### 📊 Changes **2 files changed** (+95 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/multi-session/index.ts` (+16 -10) 📝 `packages/better-auth/src/plugins/multi-session/multi-session.test.ts` (+79 -0) </details> ### 📄 Description This PR improves how sessions are listed and managed in the `multiSession` plugin. It introduces a configurable way to identify unique sessions and ensures that the returned data is properly de-duplicated. Key Changes - Unique Session Logic: Added getUniqSessionId to MultiSessionConfig. This allows developers to define how sessions are grouped (e.g., by user.id to show one entry per account, or by session.token to show every active tab/device). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds configurable unique session logic to the multiSession plugin to control how device sessions are grouped and de-duplicated. Default groups by user.id; you can override to show per-device or per-tab sessions. - **New Features** - Added MultiSessionConfig.getUniqSessionId(data: { session, user }) => string (default: user.id). - listDeviceSessions now de-duplicates using getUniqSessionId. - Tests cover default grouping and custom token-based grouping. <sup>Written for commit 197bf5d0ba32da904ba1ad32d36e4f3dfd9a7cc2. 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-03-13 13:31:01 -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#7294