Session is only stored at the end of the lifecycle, unless you use session()->save()
Can not set localization with session
I am developing an application with multiple languages. I have no problem changing the language with an action taken from the frontend. The language files have been created and are working fine. However, I created urls in that language for content in different languages so that Google bots can scan the content, but although I set the language with the session, the page comes with the default language or the previously set language at the first opening, after refreshing it opens in the language of the url, but this does not solve my problem. I don't know if I'm missing a point about the Laravel lifecycle.
For English:
Route::get('/free-qr-code-generator', function () {
session()->put('locale', 'en');
session()->put('setted', 1);
return view('FrontEnd.QrGen')
});
For French:
Route::get('/generateur-de-code-qr-gratuit', function () {
session()->put('locale', 'fr');
session()->put('setted', 1);
return view('FrontEnd.QrGen');
});
For Deutsch:
Route::get('/kostenloser-qr-code-generator', function () {
session()->put('locale', 'de');
session()->put('setted', 1);
return view('FrontEnd.QrGen');
});
But it does not open with the set language at the first opening, but after the page is refreshed, it opens in the set language.
Please or to participate in this conversation.