You can configure session storage this way
var userid = 10; sessionStorage.setItem('UserId',userid);
You will get this session variable as such
var data = sessionStorage.getItem('UserId');
Note. This variable will reset after closing the application, but if you want to save to localstorage, you will need the localStorage function, which will not reset after closing the application
Motilal soni
source share