Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 427
iRohitBhatia Avatar asked Apr 06 '26 22:04

iRohitBhatia


1 Answers

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!

like image 126
ultraGentle Avatar answered Apr 08 '26 15:04

ultraGentle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!