auth.api.getSession not refreshing session_data cookie
Hi,
I am using better-auth with sveltekit.
My auth.ts has session.cookieCache to true and maxAge of 1 second for testing purposes.
After the better-auth.session_data expires, it clears from my browser, as expected.
In my sveltekit hooks.server.ts, I'm using auth.api.getSession.
this doesn't refresh the session_data cookie. I only see the session_token instead.
If I use authClient.useSession() from client side, it refreshes the cookie. I see both session_token and session_data cookies.
Is this expected behaviour? Does api.getSession not refresh the cookie on purpose?
Solution:Jump to solution
the issue is when you use
api.getSession
it can't set the cookie in your browser unless you do it manually2 Replies