Cant manually set cookie using authClient on the server
So first up to make sense of the title. i have a sveltekit app and a hono app. hono has my auth instance and sveltekit only has access to the authClient.
Now i have a bit of a special login where i need the user to fill in something and on the server we add some parts to the username basically.
Im not sure why my approach dosent work because:
1) the signIn function works fine and returns success with data
2) I can set the cookie through sveltekit just fine
3) The auth setup itself also works. i have another login page where i directly call the authClient Signin methods on the client and there everything works fine!
BUT getSession returns me user: null session: null
So i feel like im either missing something or the cookie i manually set is somehow broken.
also let me show the values between the set-cookie header i get on succes vs the thing i parse out of it
set-cookie:
name.session_token=jItmNnCgdeLOpqJ6NHv6DzKG5rit62hp.Fz%2FVmX2%2BgqRgYSYz4NfO%2FiVoZC9c32OEjC2fxbRv3gY%3D; Max-Age=604800; Domain=.localhost; Path=/; HttpOnly; SameSite=Lax
parsedCookie:
i compared the cookies in the browser. they are the exact same
Here is the code:
5 Replies
like i genuinely dont get it. for testing i moved the logic to the frontend part and there it works fine
even the cookie i get is the exact same format
does the signin function secretly send headers that wont make the function fail but will not return user data?
This is happening in production? or in dev mode
dev mode
Why would you set the cookie manually tho? im also using hono as be and the authclient sets the cookies itself
because im calling it on the server site of my sveltekit app
(reasons dont really matter)
i even tried taking the same headers as if the client would make the request but nope
okay im mad i was missing a
decodeURIComponent for the cookieValue ffs