I am trying to logout and generate a new session id on logout
Why are you trying that?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello team, I am trying to logout and generate a new session id on logout but fail to do so..can anyone help me with that?
Following is what I have tried, Please correct me if I am wrong!! Login:
public function LoginFront(Request $request){
$attempt = [];
$login_email = $request->login_email;
$login_password = $request->login_password;
$attempt = Auth::attempt(array('email' => $login_email, 'password' => $login_password));
//dd($attempt);
if($attempt == true){
$ecomm_id = Auth::user()->id;
if($ecomm_id == 1){
$attempt = false;
return response()->json($attempt);
}else{
$request->session()->regenerate();
$request->session()->put('ecomm_id',$ecomm_id);
return response()->json($attempt);
}
}else{
return response()->json($attempt);
}
}
Logout:
public function LogoutFront(Request $request){
Auth::logout();
Session::flush();
$request->session()->regenerate();
return redirect('/');
// return '1';
}
Thanks
You put a piece of information that will help you link that session with what is in the cart. You do not force session ID.
Please or to participate in this conversation.