I have the exact same problem. Anyone :/ ?
mcamara/laravel-localization Cookies & Session Not Working
Hey,
I have searched a lot and tried many of the fixes I found but none seems to make it work. I have a prefix for the language which is always shown (domain.com/en/page or domain.com/de/page). Home page domain.com redirects to domain.com/en (which is the language defined by my browser) but when the last page I consulted from my site is in german (de), the homepage should read session or cookies to determine I want the DE one and not the EN one, but it does not do so.
Here is my code :
Routes.php
Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localize']], function()
{
Route::get('/', 'HomeController@index');
Route::get(LaravelLocalization::transRoute('routes.other'), 'OtherController@index');
});
Kernel.php
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
//Packaged Installed
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
];
I also have the package installed correctly in my config/app.php (Facade & Service Provider). Everything works except that middleware thingy for Session & Cookies.
@ARCANEDEV (I know you are an expert in this kind of things)
Please or to participate in this conversation.