title: Laravel Sanctum - Logged in user best practise
body: <p>I was wondering what is the best practise for checking that a user is still logged in client side.</p>
  <p>Let's say a user logs in. If it's successfull it will be saved in the state, something like this:</p>
  <pre><code>axios.post('/login').then(() =&gt; {
    this.state.loggedInUser = true
  });
  </code></pre>
  <p>Now if a user refreshes their browser, the state is lost, but the <code>laravel_session</code> and <code>XSRF-TOKEN</code> are still available and valid.</p>
  <p>Would it make sense to add middleware on every page reload to make a request to retrieve the current logged in user's information? Something like this?:</p>
  <pre><code>const authMiddleware = () =&gt; {
    axios.get('/user').catch(() =&gt; console.error('user is not logged in!'));
  };
  </code></pre>
  <p><strong>EDIT</strong></p>
  <p>Please be aware that I'm using Sanctum in SPA mode. So there's no tokens.</p>