Hi I have an issue with ionic login and logout.
Each time after logout, i can still click the back button and it will bring me back to my previous page. may i know how to clear or delete session when logout so that user unable to go back to previous page from the login?
var default_stat;
$scope.logout = function(){
$ionicLoading.show({template:'Logging out....'});
$localstorage.set('loggin_state', '');
$state.go('login');
$ionicLoading.hide();
$ionicHistory.clearHistory();
$ionicHistory.clearCache();
};
during login i use localstorage to indicate user has logged in
$localstorage.set('loggin_state', '1');
$ionicHistory.clearCache()
now returns promise so you can ensure cache is cleared. So you can call like this:There is no need for the above timeout like things.
credit goes to
I would do something like this:
I've found out that adding a little delay allow
$ionicHistory
to clear the cache.This is because
ionic
is caching the view, So that will stop ionic going through the controller.So you could bust the cache as follows
read here for more