title: Restrict URL access to users after login via API on Laravel
body: <p>I am logging in via Laravel API.</p>
  
  <p>Let's say that I am on www.domain.com/login. After login is successful, I put the token into a cookie and redirect to /admin. </p>
  
  <pre><code>Route::get('/admin', function () {
      return view('admin');
  })-&gt;middleware('auth');
  </code></pre>
  
  <p>The problem is that Laravel doesn't see that the user is logged in, thus redirects me to /login once more.</p>
  
  <p>And, if I declare the route as follows</p>
  
  <pre><code>Route::get('/admin', function () {
          return view('admin');
      });
  </code></pre>
  
  <p>Everyone can access www.domain.com/admin</p>
  
  <p>I appreciate any help.</p>
  
  <p>Luca</p>