inconsistent cookie settings. Move advanced.cookiePrefix in the same place as cookieName #2097

Closed
opened 2026-03-13 09:26:48 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @mariusa on GitHub (Oct 9, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Please advanced.cookiePrefix in the same place as cookieName (in session)

Current vs. Expected behavior

Current isn't consistent:

 advanced: {
        cookiePrefix: "ba",
    },
  session: {
      cookieName: "session_token",
        ...

Expected: both settings in same place

What version of Better Auth are you using?

1.3.26

System info

N/A

Which area(s) are affected? (Select all that apply)

Client, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @mariusa on GitHub (Oct 9, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Please advanced.cookiePrefix in the same place as cookieName (in `session`) ### Current vs. Expected behavior Current isn't consistent: ``` advanced: { cookiePrefix: "ba", }, session: { cookieName: "session_token", ... ``` Expected: both settings in same place ### What version of Better Auth are you using? 1.3.26 ### System info ```bash N/A ``` ### Which area(s) are affected? (Select all that apply) Client, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 09:26:48 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 9, 2025):

You're right—currently, cookiePrefix is under advanced while cookieName is under session, which is inconsistent. This separation is a design choice: cookiePrefix acts as a global prefix for all cookie names (including those used by plugins), while cookieName is specific to the session cookie. There isn't a technical reason preventing cookiePrefix from being moved under session; it's mostly organizational and could be unified for clarity. Moving it would require code changes but shouldn't break functionality if handled carefully, as both are used together to generate the final cookie names for sessions and plugins. This change would improve configuration consistency for developers. See code reference

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 9, 2025): <!-- Answer --> You're right—currently, `cookiePrefix` is under `advanced` while `cookieName` is under `session`, which is inconsistent. This separation is a design choice: `cookiePrefix` acts as a global prefix for all cookie names (including those used by plugins), while `cookieName` is specific to the session cookie. There isn't a technical reason preventing `cookiePrefix` from being moved under `session`; it's mostly organizational and could be unified for clarity. Moving it would require code changes but shouldn't break functionality if handled carefully, as both are used together to generate the final cookie names for sessions and plugins. This change would improve configuration consistency for developers. [See code reference](https://github.com/better-auth/better-auth/blob/9b1c5d885d16c5101c089f09cce13f1da64dac0b/packages/better-auth/src/cookies/index.ts) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/97df661f-a7fb-476d-9c13-a899ea91a005?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5188)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2097