I have a simple application and I want to be able to change language. In my main controller I have:
session(['applocale' => 'en']);
// $request->session()->put('applocale','en');
I know that these two lines are the same but I want to be sure that they bot does not work.
Then I have API method:
public function switchLang(Request $request, $lang)
{
error_log("Current language is: " . session('applocale'));
error_log("Current language is: " . $request->session()->get('applocale'));
}
And here error_log shows nothing.
I'm following this thread: Laravel 5.3 - How to add Sessions to API without CSRF? And in Debugbar I can see that my API function has hit middleware 'sessions' but session variables are not there.
That's how it's look like my 'seasons' middleware:
'sessions' => [
\Illuminate\Session\Middleware\StartSession::class,
]
Any ideas what I'm doing wrong?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2x3MmDs
via IFTTT
Aucun commentaire:
Enregistrer un commentaire