title: Storing and retrieving session Laravel Passport Token in React SPA App
body: <p>I want to implement a simple SPA app with Passport Auth API,</p>
  
  <p>I tried localStorage (in js) to store the token there, but it seems not secure. So I was looking for alternative.</p>
  
  <p>btw. Laravel 5.8 react 16.8</p>
  
  <pre><code>export const LogIn = formValues =&gt; async dispatch =&gt; {
      connect.post('auth/login', formValues).then(response =&gt; {
          return response;
        })
        .then(json =&gt; {
          if (json.status === 200) {
           // alert("Login Successful!");
  
            let userData = {
              email: formValues.email,
              auth_token: json.data.access_token,
              timestamp: new Date().toString()
            };
  
            let appState = {
              isLoggedIn: true,
              user: userData
            };
  
            // save app state with user date in local storage
            localStorage["appState"] = JSON.stringify(appState);
  
            return userData;
  
          } else alert("Login Failed!");
  
        })
        .catch(error =&gt; {
          let appState = {
            isLoggedIn: false,
            user: {}
          };
  
          localStorage["appState"] = JSON.stringify(appState);
  
          alert(`An Error Occured! ${error}`);
        });
  };
  
  </code></pre>
  
  <p>I can Login and Logout from my APP. Only upon refresh I am losing the tokens. I am lost here for 2 weeks already :(</p>