Why don't the session in same controller the controller?

why are session in the same controller

<?php

namespace App\Http\Controllers;

use App;

use Lang;

use Session;

use Request;

use Carbon\Carbon;

use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{


 protected $data = array('auth' =--> false );


 public function __construct(){

 $this -> auth() ;
}

 protected function auth()
{

 if( Session::has('id') )
 return $this -> data['auth'] = true;

 return $this -> data['auth'] = false;

}

 protected static function create_auth( $id )
{
 Session::put( 'id' , $id );

Session::save();

 return true;
}

}


The first method fulfills create_auth()and then redirect to the new url, butSession::get('id') - empty

the version of laravel - 5.5
June 10th 19 at 14:41
1 answer
June 10th 19 at 14:43
Solution
Because with version 5.3 session is not available in the controller's constructor. Use the crutch type
$this->middleware(function ($request, $next) {
...
 return $next($request);
 });

Find more questions by tags Laravel