[PR #3578] [MERGED] fix: Ensure session is added to context when present in cookie #4892

Closed
opened 2026-03-13 12:03:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3578
Author: @gaganref
Created: 7/24/2025
Status: Merged
Merged: 7/24/2025
Merged by: @Bekacru

Base: mainHead: fix/missing-session-context-in-get-session


📝 Commits (1)

  • 4b31919 Ensure session is added to context when present in cookie

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/routes/session.ts (+1 -0)

📄 Description

When session data is present in the cookie, get-session was early-returning without adding the session to the context, causing hooks to receive a null session.
This change ensures the session is consistently added to the context.


Summary by cubic

Fixed an issue where session data from cookies was not added to the context, which caused hooks to receive a null session. Now, the session is always set in the context when present.


🔄 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/3578 **Author:** [@gaganref](https://github.com/gaganref) **Created:** 7/24/2025 **Status:** ✅ Merged **Merged:** 7/24/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `fix/missing-session-context-in-get-session` --- ### 📝 Commits (1) - [`4b31919`](https://github.com/better-auth/better-auth/commit/4b31919d3cdcbb1d79ef97540a141acd2a2c57f4) Ensure session is added to context when present in cookie ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/session.ts` (+1 -0) </details> ### 📄 Description When session data is present in the cookie, `get-session` was early-returning without adding the session to the context, causing hooks to receive a null session. This change ensures the session is consistently added to the context. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed an issue where session data from cookies was not added to the context, which caused hooks to receive a null session. Now, the session is always set in the context when present. <!-- 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 12:03:15 -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#4892