I use Session in laravel, but when I get session in controller, it's not work.

web.php

```
Route::get('locale/{locale}',function ($locale){
    //Session::put('locale',$locale);
    session(['locale' => $locale]);
    Session::save();
    return redirect()->back();
});

```

Localization.php

```
public function handle($request, Closure $next)
{
    if(\Session::has('locale')){
        \App::setLocale(\Session::get('locale'));
        session(['locale' => \Session::get('locale')]);
        \Session::save();
    }

    return $next($request);
}

```

Kernel.php

```
protected $middleware = [
    \App\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' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \App\Http\Middleware\Localization::class,
    ],

    'api' => [
        \App\Http\Middleware\EventLogMiddle::class,
        'throttle:600,1',
        'bindings',
    ],
];

```

MachCtrl.php (extends Controller)

```
public function index()
{
    $lang = session('locale');
    $config = json_encode([
        "table" => "Machine_list",
        "title" => "machine list",
        "rows" => 20,
        "column" => [
            "Machine_id", "VM_name", "Machine_location","IP_address", 
            "Network_status", "Current_status"
        ],
        "CUDP" => "0111",
        "CreateRoute" => route('machine.create'),
        "DeleteRoute" => route('machine.destroy'),
        "UpdateRoute" => route('machine.editInfo'),
        "locale" => $lang,
    ]);

    return view('table.show')->with(['config' => $config, 'lang' => 
                                                            $lang]);
}

```

I save Session in router and middlemare, it's not work.

But when I put Session in Controller, it's work. As following code:

```
public function index()
{
    session(['locale' => 'en']);
    $lang = session('locale');
    $config = json_encode([
        "table" => "Machine_list",
        "title" => "machine list",
        "rows" => 20,
        "column" => [
            "Machine_id", "VM_name", "Machine_location","IP_address", 
            "Network_status", "Current_status"
        ],
        "CUDP" => "0111",
        "CreateRoute" => route('machine.create'),
        "DeleteRoute" => route('machine.destroy'),
        "UpdateRoute" => route('machine.editInfo'),
        "locale" => $lang,
    ]);

    return view('table.show')->with(['config' => $config, 'lang' => 
                                                           $lang]);
}

```

I really want to know what happen in my project.
Thanks.

Edit:
I use dd(session()) in my code:

-web.php

```
Route::get('locale/{locale}',function ($locale){
    Session::put('locale',$locale);
    Session::save();
    dd(session());
    return redirect()->back();
});

```

Result:

[![enter image description here](https://i.stack.imgur.com/49g3F.png)](https://i.stack.imgur.com/49g3F.png)

-Localization.php

```
public function handle($request, Closure $next)
{

    if(\Session::has('locale')){
        \App::setLocale(\Session::get('locale'));
        session(['locale' => \Session::get('locale')]);
        //dd(session());
        \Session::save();

    }

    return $next($request);
}

```

Result:

[![enter image description here](https://i.stack.imgur.com/qCFXK.png)](https://i.stack.imgur.com/qCFXK.png)

-MachCtrl.php

```
public function index()
{
    dd(session());
    $lang = session('locale');
    $config = json_encode([
        "table" => "Machine_list",
        "title" => "machine list",
        "rows" => 20,
        "column" => [
            "Machine_id", "VM_name", "Machine_location","IP_address", 
            "Network_status", "Current_status"
        ],
        "CUDP" => "0111",
        "CreateRoute" => route('machine.create'),
        "DeleteRoute" => route('machine.destroy'),
        "UpdateRoute" => route('machine.editInfo'),
        "locale" => $lang,
    ]);

    return view('table.show')->with(['config' => $config, 'lang' => 
                                                            $lang]);
}

```

Result:[![enter image description here](https://i.stack.imgur.com/VZUlh.png)](https://i.stack.imgur.com/VZUlh.png)