title: laravel session not persisting when view returned
body: <p>I am building a laravel application where I have web and api routes.
  I want to store sessions between my routes.
  If i store as session without returning a view, it works fine.
  But when i return a view my session no longer exists.</p>
  
  <p>My web.php is as follows:</p>
  
  <pre><code>Route::get('/', 'ViewController@index');
  Route::get('/check', 'ViewController@check');
  </code></pre>
  
  <p>My controller</p>
  
  <pre><code>public function index(Request $request)
  {
      $request-&gt;session()-&gt;put('test','123456');
      $request-&gt;session()-&gt;save();
  
      //echo $request-&gt;session()-&gt;get('test', 'default_value');
  
      // return view('welcome'); //If I uncomment this the sessions are not working anymore.
  }
  
  public function check(Request $request)
  {
      echo $request-&gt;session()-&gt;get('test', 'default_value');
      var_dump($request-&gt;session()-&gt;all());
      //return view('welcome');
  }
  </code></pre>
  
  <p>Maybe it has something to do that i also store sessions in my api routes in the api controllers. My api.php:</p>
  
  <pre><code>Route::group(['middleware' =&gt; ['web']], function () {
      //board
      Route::get('/board/create', 'BoardController@create');
      Route::post('board/{id}/guess', 'BoardController@guessWord');
  
      Route::get('/board/set', 'BoardController@set');
      Route::get('/board/get', 'BoardController@get');
  
      //user
      Route::get('/user', 'UserController@get');
      Route::post('/user/create', 'UserController@create');
  });
  </code></pre>
  
  <p>kernel.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http;
  
  use Illuminate\Foundation\Http\Kernel as HttpKernel;
  
  class Kernel extends HttpKernel
  {
  /**
   * The application's global HTTP middleware stack.
   *
   * These middleware are run during every request to your application.
   *
   * @var array
   */
  protected $middleware = [
      \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
      \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
      \App\Http\Middleware\TrimStrings::class,
      \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
      \App\Http\Middleware\TrustProxies::class,
  ];
  
  /**
   * The application's route middleware groups.
   *
   * @var array
   */
  protected $middlewareGroups = [
      'web' =&gt; [
          \App\Http\Middleware\EncryptCookies::class,
          \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
          \Illuminate\Session\Middleware\StartSession::class,
          // \Illuminate\Session\Middleware\AuthenticateSession::class,
          \Illuminate\View\Middleware\ShareErrorsFromSession::class,
          \App\Http\Middleware\VerifyCsrfToken::class,
          \Illuminate\Routing\Middleware\SubstituteBindings::class,
      ],
  
      'api' =&gt; [
          'throttle:60,1',
          'bindings',
      ],
  ];
  
  /**
   * The application's route middleware.
   *
   * These middleware may be assigned to groups or used individually.
   *
   * @var array
   */
  protected $routeMiddleware = [
      'auth' =&gt; \Illuminate\Auth\Middleware\Authenticate::class,
      'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
      'bindings' =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class,
      'cache.headers' =&gt; \Illuminate\Http\Middleware\SetCacheHeaders::class,
      'can' =&gt; \Illuminate\Auth\Middleware\Authorize::class,
      'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
      'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
  ];
  }
  </code></pre>
  
  <p>Thanks!</p>