Hello everyone in here.
I have chosen the laravel's database session method and want to store each registering user's Id in my sessions table precisely in the 'user_id' so that I can check if a user is connected or not.
For that I processed this way
In the controller file
Class RootController{
Public function registration(Request $request) {
$request->validate([
'prenom' => ['required',....],
'nom' => ['required',....],
'mail' => ['required',....],
'password' => ['required',....]
]) ;
/*now I create the user's account*/
$user= Client::create([
'prenom' => $request->prenom,
'nom' => $request->nom,
'mail' => $request->mail,
'password' => Hash::make($request->password)
]);
/*then now I insert the id of the user just registered*/
session(['user_id' => $user->id]);
});
return Redirect::To("logged_in/". $user->id);
}
}
In order to store the user's Id in sessions.user_id colomn.
Subsequently, the sessions.user_id column remains filled with Null after registration, any help please, .