I am using @dfinity/auth-client@0.11.1, and I want to store the authentication state in the browser’s session storage instead of local storage.
const options: AuthClientCreateOptions = {
storage: new LocalStorage(
‘myprefix-‘, window.sessionStorage
),
};
const authClient = await AuthClient.create(options);
This works fine in a single tab, but when opening links in a new tab, the user is no longer logged-in. When I look at the session storage in Chrome Dev Tools, I can see that it exists in the original tab, but not the new tab.
In contrast, if I do not specify a storage option, leaving the default to local storage, I stay logged-in across tabs, and I can see the authentication data in the local storage of all tabs using Chrome Dev Tools.
The motivation to use session storage is because all session data is lost when all tabs in the session are closed. This is preferred for security so that another user can not open the website later and continue the session.
Is session storage supported? If so, am I using the API correctly? Thanks.