I want to set a cookie lang with a value x by the route /setLang/x. This is my code in the routes\web.php directory:
Route::get('/setLang/{lang}', function($lang){
if(App\Helper\Language::isAllowed($lang)){
App::setLocale($lang);
Cookie::queue('lang', $lang, (60 * 24 * 30), "/");
}
return view('layouts.index');
});
The layouts/index.blade.php shows the cookie:
<body>
</body>
However, it always returns the old cookie, not the new one. Example (assuming the Cookie with key lang is set to en):
Input: http://ift.tt/2wtZbVj Output: en Input: http://ift.tt/2wtZbVj Output: de Input: http://ift.tt/2khMewh Output: de Input: http://ift.tt/2khMewh Output: en
Is it possible to set cookie so that it is correctly set in the first time where one receives the view?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire