B
B
boban222021-04-11 17:28:46
HTTP Cookies
boban22, 2021-04-11 17:28:46

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);
    }

and exit
public function logout(Request $request)
    {
        $cookie = Cookie::forget('jwt');
        return response([
            'message' => 'Success'
        ])->withCookie($cookie);
    }

here is a postman
unknown.png
unknown.png
and a cookie browser
unknown.pngcreated, the user was returned,
unknown.png?width=1363&height=677
unknown.png?width=1278&height=678
although it wrote that it worked, but the cookies remained

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question