Javascript – How to save Token to Local Storage


I'm working on a login system for an app in school. I can register a user that gets saved to my azure documentDB. I can then, sort of log in with the user. But it (the Token) never gets saved so that I can access the token…

The script for the log in looks like this:

      var signin = function() {

            var tokenUrl = "http://localhost:15746/Token";
            var loginData = $("#userSignup").serialize();
            loginData = loginData + "&grant_type=password";
            $.post(tokenUrl, loginData).then(navigateToEvent);
            return false;


How could I store the Token? In Local Storage? How?

Best Solution

To save a string in Local Storage you use

window.localStorage.setItem(key, value);

You can get the value later with: