Reputation: 459
window.localStorage['uname'] = Username; window.localStorage['pass'] = password;
Hi, I am trying to save my user name and password permanently for remember me functionality. I am using the above code for that but when I terminate the app then re-open it the local storage is getting drained. How can I save the login credential?
Upvotes: 0
Views: 2754
Reputation: 5064
I personally inject $window
into my controller and services to access localStorage and to set my variable $window.localStorage[key] = value
And to get my variable just access it like this: $window.localStorage[key]
However, storing your login & password within your app is not a very good idea. Remember me shall be implemented on server side.
Upvotes: 0
Reputation: 3803
LocalStorage is persistent. It will not be deleted till the user delets the Application. Do you maybe define the localStorage-Values at another line of code to 0
or null
? The issue has to be inside your code. Please provide a full code snippet or more Code.
I just tried it:
localStorage.username = username;
localstorage.password = password;
closed the application, re-opened it, the data is still there.
Upvotes: 1