Alwaysblue
Alwaysblue

Reputation: 11830

Getting Firebase session across all tabs

I am not sure what code I need to share but it appears so that every-time I login, my firebase-functions session is maintained across that very tab, meaning if in my browser, I have logged in through one tab and open a new tab, i need to login again.

How can I make my firebase function session consistent i.e if open in one tab, I don't need to open across another tab.

This is thread which seemed relevant but it's been some time since OP posted it.

https://groups.google.com/forum/#!topic/firebase-talk/zkrJsCh0_sw

Upvotes: 3

Views: 1919

Answers (1)

ultraGentle
ultraGentle

Reputation: 6309

If I'm interpreting your question correctly, you

  1. have a Firebase app that allows users to log in, and
  2. you want a logged-in user to be able to open a new tab, and automatically be logged in there as well

You can do so by adding the following line to your front-end code, at a place where the Firebase SDK is initialized and available:

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

Instead of LOCAL at the end, the other two options are SESSION and NONE, each of which gets progressively more restrictive with how it allows users to remain logged in.

Note that LOCAL is the default, so you may wish to check whether this setting has already been changed elsewhere in your code.

Note also that the capital letters are correct.

You can read more about the options and see a more detailed example of how to implement this code at the official Firebase docs on persistence

If that's not what you're asking about, you may wish to consider clarifying your question to indicate how my assumption 1. or 2. are incorrect. Cheers!

Upvotes: 6

Related Questions