#Best practice to check user's login status between protected routes

3 messages · Page 1 of 1 (latest)

strange loom
#

My backend server returns a https only session cookie when login is successful. but the thing is I have 2 protected routes say, A and B pages.
I have getServerSideProps for both pages, calling my backend server and see if the user is logged in or not. but the problem happens when I move from A page to B page, resulting making 2 requests. Is there a better way for this when dealing with https only session cookies? changing this session cookie to jwt token is not an option for me. Thank you!

#

Since it's a http only cookie, I'm not able to access through javascript so in order for me to check whether the user is logged in, i'd have to make a request to server.

frozen mason
#

use server action