title: How to switch Authentication from one user to another using Laravel
body: <p>Firstly, I login as user X, and I have a function like:</p>
  
  <pre><code>public function loginAs($userId)
  {
      Auth::loginUsingId($userId); // now use Y user
      return response()-&gt;json(['logged' =&gt; Auth::check(), 'user' =&gt; Auth::user()]);
  
  }
  </code></pre>
  
  <p>and when I try to print out <code>Auth::check()</code> it returns <strong>TRUE</strong> which is fine so far I am logged now as user Y, the thing is that I do first login as an X user and then switch to another Y user but when I do call some other functoins it seems that the current user logged is still X, and I want to be Y the current user logged... This might have to do something with session or I dont know exactly how to do this thing, would be grateful if someone has any sample or have any idea how to achieve such things in Laravel 5.</p>