I am trying to implement a one-page application that starts with a login form. For the front end I use AngularJS.
In the login controller, I check the authentication data, and if everything is ok, I set a cookie (using the $ cookieStore service) with some user data and send it to a different view. Here, in the controller of the second view, I check if the user is empty from the cookie, and if so, I redirect to the login view.
What I want to do is when the user closes the browser or, if he leaves the page, removes the cookie. I tried to use:
$scope.$on("$locationChangeStart", function(){
$cookieStore.remove('user');
});
or
$scope.$on("$destroy", function(){
$cookieStore.remove('user');
});
.
, (cookie ) , / (cookie ). URL- , , cookie , .
- ?