title: Session Dying Right After Calling Auth::login()
body: <p>Stackoverflow community! We've been struggling with this issue for a while now. We're attempting to upgrade our Laravel v4 site to Laravel v7. So far, it's been fine. When we use our login function, it properly authorizes the user, but upon redirect, the session gets killed. We've checked it over and over again, but we simply cannot find anything that could be the cause of the issue. Here is the suspect function:</p>
  
  <pre><code>public function loginv2()
  {
      if (Auth::check()) {
          return Redirect::action('FrontController@showWelcome')-&gt;withMessage("Already logged in.");
      }
  
      if (!Auth::check() &amp;&amp; !isset($_GET['token']))
      {
          $_SESSION['redirect'] = "https://zjxartcc.org";
          header("Location: https://login.vatusa.net/uls/v2/login?fac=ZJX");
          exit;
      }
  
      $token = $_GET['token'];
      $parts = explode('.', $token);
      $token = $this-&gt;base64url_decode($parts[1]);
  
      $jwk = json_decode('{"alg":"HS256","use":"sig","kty":"oct","k":"..."}',   true);
  
      $algorithms = ['HS256' =&gt; 'sha256', 'HS384' =&gt; 'sha384', 'HS512' =&gt; 'sha512'];
  
      if (!isset($algorithms[$jwk['alg']])) {
          return Redirect::action('FrontController@showWelcome')-&gt;withMessage("Invalid Operation");
      }
  
      $sig = $this-&gt;base64url_encode(hash_hmac($algorithms[$jwk['alg']], "$parts[0].$parts[1]", $this-&gt;base64url_decode($jwk['k']), true));
  
      if($sig == $parts[2]) {
  
          $token = json_decode($token, true);
  
          if($token['iss'] != 'VATUSA') {
              return Redirect::action('FrontController@showWelcome')-&gt;withMessage("Not issued from VATUSA");
          }
          if($token['aud'] != 'ZJX') {
              return Redirect::action('FrontController@showWelcome')-&gt;withMessage("Not issued for ZJX");
          }
  
          $client = new GuzzleHttp\Client();
          $url = "https://login.vatusa.net/uls/v2/info?token={$parts[1]}";
          $result = $client-&gt;get($url);
          $res = json_decode($result-&gt;getBody()-&gt;__toString(), true);
  
          $userstatuscheck = User::find($res['cid']);
          if($userstatuscheck) {
              if($userstatuscheck-&gt;status == 1) {
                  return Redirect::action('FrontController@showWelcome')-&gt;withMessage("You are not an active controller, and cannot login.");
              } else {
                  Auth::login($userstatuscheck, true);
  
                  require("/home2/zjxartcc/public_html/forum/smf_2_api.php");
                  smfapi_login($userstatuscheck-&gt;id);
                  setcookie("ids_loggedin", $res['cid'], 0, "", ".zjxartcc.org");
                  $_SESSION['loggedin'] = $res['cid'];
              }
          } else {
              return Redirect::action('FrontController@showWelcome')-&gt;withMessage("No user matching your information on the roster.");
          }
  
          //update email records and rating
          $forum = SMFMember::find($res['cid']);
          $forum-&gt;email_address = $res['email'];
          $forum-&gt;save();
          $member = User::find($res['cid']);
          $member-&gt;rating_id = $res['intRating'];
          $member-&gt;email = $res['email'];
          $member-&gt;save();
  
  
          return Redirect::action('FrontController@showWelcome')-&gt;withMessage('You have been logged in!');
  
      } else {
          return Redirect::action('FrontController@showWelcome')-&gt;withMessage("Bad Signature");
      }
  }
  </code></pre>
  
  <p>All help and suggestions are greatly appreciated! Thank you!</p>