session returning null
Hi guys,
Question. I have implemented better-auth into my express.js server and I got it working with email and password (sign-up/in) but when it comes to getting a session I get a status code of 200 but a null in return.
Basically just followed the docs on installation and under integration of Express. But is there some 
headers object that I need to catch to get the session or have I missed a step?

25 Replies
i also getting the same response null , if you solved the problem , please share with me
This has not happened to me earlier in other frameworks but for some reason it happens now. Curious if it has to do with the 
headers (as we need to pass something special) or missing a frontend.did session created on login?
Yes. I can even see it in the drizzle studio

i am testing in postman , on login with email and password my sessions are not generated and login with google works fine 
frontend in React
backend in Express
Well that must be in your 
auth.ts ?
Well if I did read it right in the docs our auth.ts should look something like this
this is my controller to retrieve session 
and this is my auth.ts


Wait your using 
auth.api.getSession()but shouldn't you be using the auth-client.ts file instead?
And then follow that with
So you would do something like authClient.useSession()this file auth-client.ts  i am using this in my frontend 
did i have to use this file in backend


Ok but your function 
getCurrentUser()where is that from?
Your backend or frontend?in backend
Aaa ok. I'm stupid 🤣
I have no idea man. Seems to be a problem that I cannot solve. Waiting for help
nobody has made a yt video on this configuration ðŸ˜
ok bro , thanks for your time
@Luv Sharma I fixed it. I can explain when your available. I had some help from one of the admins.
To get your session on the server side or from postman you need to pass in 
headers a cookie named better-auth.session_token=YOUR_TOKEN_GOES_HERE and you will get your user session from Postman/httipie or simular programsthe problem is sessions are not created on my backend when i am using this ( Img 1 )
but , when i directly signin on my frontend with this logic ( Img 2 ) , session are created , 
here's what i learn :
When we use auth.ts ( on backend ) file to signIn user , the sessions are not created , 
but when we use auth-client.ts ( on frontend ) file to signIn user directly without backend , the session are created :
that is the same problem i faced in nextjs also , 
moral of the story : auth.ts does not created sessions 
here's the video proof :



1. We want to fix the backend before we do anything else in the frontend.
2. After we get the backend working we can make it work with the frontend.
Let's together try to sort this problem then. Can you make an API endpoint in your backend that hits the following endpoint 
app.all("/api/auth/*splat", toNodeHandler(auth));
After you have added the endpoint in your backend then hit the following endpoint: /api/me
and don't forget to include the better-auth.session_token=YOUR_TOKEN_GOES_HERE in your headersdid your sessions are created on backend , can u show me your code ?
Yes my session are created in Node+express.js
can u show me the code bro?
i have also done that , but still not sessions are created
Which part do you want to see that I have not shown you?
Here is the 
index.ts file
Here is my auth.ts
Hi , bro
is Your express + better auth working good ?
Hi @Luv Sharma  is it working for you now ?