[GH-ISSUE #2184] admin_session cookie doesn't respect the configured cookie prefix #26413

Closed
opened 2026-04-17 16:58:29 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @MarcMogdanz on GitHub (Apr 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/2184

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Impersonate another user to trigger the creation of the admin_session cookie

Current vs. Expected behavior

Instead of admin_session the cookie should be called $prefix.admin_session just like the normal $prefix.session_token

What version of Better Auth are you using?

1.2.5

Provide environment information

-

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { admin } from 'better-auth/plugins'
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  advanced: {
    cookiePrefix: 'prefix',
  },
  plugins: [admin()]
});

Additional context

No response

Originally created by @MarcMogdanz on GitHub (Apr 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/2184 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Impersonate another user to trigger the creation of the `admin_session` cookie ### Current vs. Expected behavior Instead of `admin_session` the cookie should be called `$prefix.admin_session` just like the normal `$prefix.session_token` ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { admin } from 'better-auth/plugins' export const auth = betterAuth({ emailAndPassword: { enabled: true }, advanced: { cookiePrefix: 'prefix', }, plugins: [admin()] }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 16:58:30 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Apr 12, 2025):

i dont think there is an issue of using the name ofadmin_session. it is just sth that we used to keep track the admin while impersonating.

<!-- gh-comment-id:2798817614 --> @Kinfe123 commented on GitHub (Apr 12, 2025): i dont think there is an issue of using the name of`admin_session`. it is just sth that we used to keep track the admin while impersonating.
Author
Owner

@MarcMogdanz commented on GitHub (Apr 13, 2025):

i dont think there is an issue of using the name ofadmin_session. it is just sth that we used to keep track the admin while impersonating.

I get the use case, but I don't get why it's not using the prefix since it's also just a cookie like the actual session token.

In the docs it says cookiePrefix: Prefix for cookies so I'd assume this goes for all cookies set by better-auth

<!-- gh-comment-id:2799887833 --> @MarcMogdanz commented on GitHub (Apr 13, 2025): > i dont think there is an issue of using the name of`admin_session`. it is just sth that we used to keep track the admin while impersonating. I get the use case, but I don't get why it's not using the prefix since it's also just a cookie like the actual session token. In the docs it says [`cookiePrefix: Prefix for cookies`](https://www.better-auth.com/docs/reference/options#advanced) so I'd assume this goes for all cookies set by better-auth
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26413