How to keep the user logged even if he closes the app


Hi. I’ve been searching for this but ican’t find a good answer. I’m a beginner with Ionic and I want the user to stay logged in even if he closes the app. How can i make it work ? do I have to use localstorage ? but how ? Thanks


Here some sample code of something you can do. You will need to implement your own logic to determine if the user is already logged in. But you could possibly save user Information using window.localStorage.

$ionicPlatform.ready(function() {
  if (AuthService.isLoggedIn()) {
  else {
...(rest of your ready code)


or if you want to be safe, that the localstorage is not cleared after os updates or something use persistent storage (a json-file) or sqlite plugin.


Thank you so much for your help


Thank you so much for your help