Skip to main content

Posts

Showing posts with the label Auto redirect to home/login page at session timeout

Redirect to login page after session expires AngularJs | $cookieStore

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' )){        ...