Adeel
Adeel

Reputation: 23

User logout after refreshing the page

I am using Firebase authentication. After authentication when refresh the page user is logged out.

I have this in my index.js file but it doesn't work.

firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION);

Upvotes: 1

Views: 4298

Answers (1)

mcmartin
mcmartin

Reputation: 106

Usually you need to store the session. It's really common save sessions at localstorage.

Actually it have a lot of implementation of packages to control this things and make this transparent for you. But in the practice you need to find some way to store the session and when the page reloads you need to verify if the session that you have stored is valid.

Read about this. Some good references: Where to Store Tokens, Session Storage and Local Storage in React

Upvotes: 1

Related Questions