dipesh
dipesh

Reputation: 19

how to maintain session step by step in angular 4

I am new in Angular 4. Please explain How to implement session functionality in angular 4. Step by step process and where to write code for that. i am trying to implement below code but need direction to implement

saveInLocal(key, val): void {
    console.log('recieved= key:' + key + 'value:' + val);
    this.storage.set(key, val);
    this.data[key]= this.storage.get(key);
   }

Upvotes: 1

Views: 216

Answers (1)

Kevin
Kevin

Reputation: 847

Wherever you want to set session info you can just do

window.sessionStorage.setItem('myKey', myValue);

to get it:

const sessionValue = window.sessionStorage.getItem('myKey');

Upvotes: 1

Related Questions