Preventing having to log in again when restarting the app

#1

I have an app that authenticates with a Rails backend and uses fetch with credentials: 'include' in the params to log in and then in each request. This works as long as I keep the app open. But if I close it and restart it the cookie is gone and I need to login again, which is a bit annoying. Is there a way I can store this cookie or do something else so that the user doesn’t have to keep logging in every time they restart the app?

0 Likes

#2

Coookie? You should handle user session as you do in single page application.
Don’t use session cookie but a token instead.

You don’t have to go for JWT, you can simply generate a random unique token and authorize the user with it. Please read about token authentication if you haven’t done that before! Lots of resources out there.

0 Likes

#3

Yes, we are going to transition to tokens soon I hope, it’s a better solution. But in the meantime I’m investigating a quick fix with cookies would work.

0 Likes

closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

0 Likes