Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to destroy jwt token on logout at server side php #540

Open
gamotmohit opened this issue Oct 19, 2023 · 1 comment
Open

how to destroy jwt token on logout at server side php #540

gamotmohit opened this issue Oct 19, 2023 · 1 comment

Comments

@gamotmohit
Copy link

gamotmohit commented Oct 19, 2023

There is no code available which can tell how can we destroy JWT token on server in PHP.

@GuiiSantos
Copy link

       if(isset($_SESSION['jwt_token'])) {
            unset($_SESSION['jwt_token']);
            $response = ["message" => "Destroyed session token"];
            echo json_encode($response);
        } else {
            $response = ["message" => "User is not logged in"];
            echo json_encode($response);
        }

You can use the unset function in PHP to destroy a JWT token stored in a session, as shown in your provided code. This will effectively remove the token from the session, making it invalid for future requests.

Good luck with your implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants