How to redirect to login page after session expires using $cookieStore?
A cookie is a small piece of data sent from a
website and stored on the user's machine by the user's web browsers while the user
is browsing.
In the below code, we are stored in the cookie’s expiry
time. If the application cookie
is expired the page will redirect to login or where you want to redirect this
page.
As
an Example,
var date = new Date();
//set expire time
date.setTime(date.getTime() + (60*1000));
//set expire time in te cookie store
$cookieStore.put('app_user', appUser.name, {expires : date });
$timeout(function(){
//check if expired session then simply rediect to login
if(!$cookieStore.get('app_user')){
$window.location.href = baseUrl + 'Account/Login';
}
},60);
Must see this
Angular Cookies FAQs