Session expires in 5 minutes. Regardless of 1 year settings. Two Set-Cookie headers
Hey, I have this setting for the session:
But my users are reporting to be logged out after 5 minutes.
I've noticed that when I get cookie via email-otp, it has two Set-Cookie headers that look like that
better-auth.session_token=; Max-Age=31536000; Domain=.mydomain.com; Path=/; HttpOnly; Secure; SameSite=NoneI
set-cookie
better-auth.session_data=; Max-Age=300; Domain=.mydomain.com; Path=/; HttpOnly; Secure; SameSite=None
As you can see the one cookie Max-Age is really long, and the second is just 300 seconds.
Several questions:
1. Why there are two cookies?
2. How do I fix that? I want a max age for my cookies session
6 Replies
Also here is my
get-session
response
It seems like the session is expired as soon as it's createdYou have two cookies because you've enabled cookie cache
Session Management | Better Auth
Better Auth session management.
If a session expires in exact 5 minutes, the issue might be related to cookie cache. Try disabling it and see
It solved the problem, but is it an expected behavior?
+1, this is an unexpected behavior with cookie cache