Reputation: 427
There are only two points in the application where the login should appear:
- When I am not logged in and I attempt to visit a page that requires login, e.g. my profile page.
- When I attempt to make a request that requires a login, e.g. my session has expired whilst I’m attempting to post something.
Upvotes: 0
Views: 75
Reputation: 279
With angularJS :
$window.sessionStorage.setItem('key', 'value')
scope.name = $window.sessionStorage.getItem('key')
Here is a small example : http://jsfiddle.net/gioeleslfierro/s0pm6gcq/
I suggest you to use the angular way with $window. But if you want to do it by yourself its pretty similar (source) :
// Save data to sessionStorage
sessionStorage.setItem('key', 'value');
// Get saved data from sessionStorage
var data = sessionStorage.getItem('key');
// Remove saved data from sessionStorage
sessionStorage.removeItem('key');
// Remove all saved data from sessionStorage
sessionStorage.clear();
Upvotes: 1
Reputation: 456
use HtML5 $sessonStorage or $localStorage.
Example
--------
sessionStorage.setItem('id', userId);
sessionStorage.getItem('id');
Upvotes: 1