Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to store data(ng2Idle.main.expiry) in sessionStorage Instead of localStorage?? #104

Open
madhujsmg opened this issue Jun 27, 2018 · 3 comments

Comments

@madhujsmg
Copy link

madhujsmg commented Jun 27, 2018

I tried to find solution in ng2-idle documents but am not finding satisfactory information ,

The issue with if one browser window is active and other window timeout is not happening

is there any way to store data in session instead of localStorage???

@madhujsmg madhujsmg changed the title How store data(ng2Idle.main.expiry) in sessionStorage Instead of localStorage?? How to store data(ng2Idle.main.expiry) in sessionStorage Instead of localStorage?? Jun 27, 2018
@KellenHe
Copy link

KellenHe commented Jul 1, 2020

Hi @madhujsmg
do you find the solution ? I also want to use session instead of localStorage

@adampicker
Copy link

I would really appreciate the solution

@elaihau
Copy link

elaihau commented Nov 2, 2020

Implement your own provider for storing the data:

import { LocalStorage } from '@ng-idle/core';

export class MyStorage extends LocalStorage {
    constructor() {
        super();
        if (sessionStorage) {
          this['storage'] = sessionStorage;
        }
    }
}

and in your module:

import { LocalStorage } from '@ng-idle/core';
import { MyStorage } from './my-storage';

@NgModule({
  providers: [
    { provide: LocalStorage, useClass: MyStorage },
  ],
})

My personal suggestion to the maintainer of this repo is making the private storage a protected variable in the LocalStorage class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants