You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem on a Laravel 10.x project
I'll start by saying that I have always used the same procedure and have never had any problems of this type
I have a multilingual site, customers arrive on the home page, make a transfer reservation by entering
departure, Arrival
and departure time
when they press the "booking" button they are redirected to a summary page where they are saved via controller all data in session
public function traduzione(Request $request,$locale)
{
$allreq=$request->all();
session()->put('locale', $locale);
App::setLocale($locale);
return redirect()->back()->withInput($allreq);
}
and
for information this is the middleware
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
class Localization
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (Session::has('locale')) {
App::setLocale(Session::get('locale'));
}
dd(Session()->all());
return $next($request);
}
}
the problem occurs right here, because when you return to the summary page, the form is no longer filled in with the session data and the session itself dd(Session()->all()) is empty
the strange thing I noticed is that if I go back from the browser and reload the page, I have the session data and the language selected again, I don't know how to solve it, can anyone help me?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a problem on a Laravel 10.x project
I'll start by saying that I have always used the same procedure and have never had any problems of this type
I have a multilingual site, customers arrive on the home page, make a transfer reservation by entering
departure, Arrival
and departure time
when they press the "booking" button they are redirected to a summary page where they are saved via controller all data in session
this is my route
and this is my controller
the data is saved correctly and the session data relating to the booking is displayed in the summary form.
the problem occurs as soon as I try to change the language from this page
this is route for change lang
function traduzione():
and
for information this is the middleware
the problem occurs right here, because when you return to the summary page, the form is no longer filled in with the session data and the session itself dd(Session()->all()) is empty
the strange thing I noticed is that if I go back from the browser and reload the page, I have the session data and the language selected again, I don't know how to solve it, can anyone help me?
Beta Was this translation helpful? Give feedback.
All reactions