session carryover to new window lost #237
-
Hello, I'll start with note that I am new to web domain and may be this query might sound silly... I would really appreciate it if you can help me to fix this Issue. (Most probably It is at my end 🤔) file hierarchy:
I have integrated fief, IDM works as expected in base url, and also if I open data.html in same window. But, when I open data.html in new window with my base url still open and having signed in user. I get Is there a way to carry over the session to new window? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hail, @QnalNandi 👋 Welcome to Fief's kingdom! Our team will get back to you very soon to help. In the meantime, take a minute to star our repository ⭐️ Farewell! |
Beta Was this translation helpful? Give feedback.
-
From what I understand, you directly open the HTML file in your browser, right? If so, you won't be able to make the code work correctly, as browsers have specific restrictions for plain HTML files. If you want to run the example for real, you need to serve it by running a web server on your local machine, like it would be done by a real server. There are a few ways to do it. For example, you can use |
Beta Was this translation helpful? Give feedback.
-
thanks for the response @frankie567 this is how I have anchored <base.html> |
Beta Was this translation helpful? Give feedback.
-
Oh, okay, I understand now. The thing is, by default, our browser integration uses
If you want to solve that, you can switch to localStorage, which is similar but keeps the data in memory even after the page is closed. It's not built-in in our SDK, but since const initialize = () => {
const fiefClient = new fief.Fief({
baseURL: 'https://example.fief.dev',
clientId: 'YOUR_CLIENT_ID',
});
const fiefAuth = new fief.browser.FiefAuth(fiefClient);
// Change the underlying storage
fiefAuth.storage.storage = window.localStorage; |
Beta Was this translation helpful? Give feedback.
Oh, okay, I understand now. The thing is, by default, our browser integration uses
sessionStorage
, which works only in a single window/page. It's not carried over a new window/tab. From MDN:If you want to solve that, you can switch to localStorage, which is similar but keeps the data in memory even after the page is closed.
It's not built-in in our SDK, but since
sessionStorage
andlocalStorage
have the same API, it can actually be done quite easily: