Remember me cookie
Unanswered
Black Caiman posted this in #help-forum
Black CaimanOP
Hello , i have external api and i want to implement remember me feature where when the user not click on it the cookie that contain unauthorzied will expire as soon as the user close the browser
2 Replies
Sun bear
Have you looked into working with cookies? Is there relevant code that's not working?
@Black Caiman Hello , i have external api and i want to implement remember me feature where when the user not click on it the cookie that contain unauthorzied will expire as soon as the user close the browser
Spectacled Caiman
Hey, for the remember me feature you want to set the auth cookie without an expires or max-age value when the user doesn't check remember me, that makes it a session cookie which gets deleted as soon as they close the browser. When they do check remember me, set the same cookie but with an explicit expires date like 7 or 30 days out so it persists. Make sure both are httpOnly, secure and sameSite for security. On the backend just validate the token from whichever cookie is present and handle it the same way