Answer the question
In order to leave comments, you need to log in
Deleting cookies in the browser does not work, how to fix it?
When I log in, I create cookies, but when I log out, they are not deleted, although everything works in the postman. Here is the code:
public function login(Request $request){
if(!Auth::attempt($request->only('email','password'))){
return response([
'message' => 'invalid credentials',
], Response::HTTP_UNAUTHORIZED);
}
$user = Auth::user();
$token = $user->createToken('token')->plainTextToken;
$cookie = cookie('jwt', $token, 60*24, '/', '', false, true, 1, 'none');
return response([
'messages' => 'Success',
'token' => $token,
])->withCookie($cookie);
}
public function logout(Request $request)
{
$cookie = Cookie::forget('jwt');
return response([
'message' => 'Success'
])->withCookie($cookie);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question