Dears Will u Help me. Please explain this Code

GPS.factory(‘AuthenticationFactory’, function($window, $rootScope){

var auth = {
	isLogged: false,
	check: function() {
		if($window.sessionStorage.token && $window.sessionStorage.user ){
			this.isLogged = true;
			this.token = $window.sessionStorage.token;
			this.user = $window.sessionStorage.user;
		} else {
			this.isLogged = false;
			this.user = null;
		}
	}
}

return auth;

});

What really you need?

This code just check if there is a ‘token’ and a ‘user’ key in sessionStorage.

If true, then set isLogged to true, and token and user to the sessionStorage values

:\

where will be the storage space? can we see that space? can we access globally?

The sessionStorage of the browser is only valid for a single browser instance or tab.
If you close the tab, the session storage is emptied again!
The data inside the sessionStorage can also only be accessed from the same tab!

Just type “sessionStorage” in the developer console and you can check the data of this sessionStorage!

1 Like

Thanks Dear…
I can understand