JWT

This tutorial is about JWT: HOW TO SEND HEADER AUTHORIZATION TOKEN IN PHP.

I‘m not gonna bore you with what JWT is and what it’s not, I guess you know that already. You are here because you want to know how to send a JWT authorization token in the PHP header. If you are using Apache, then the headers will probably not come through. You will need to add the following to your virtual host or.HTACCESS

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

Once you have the above line in your server, then you can access it from $_SERVER.

$token = $_SERVER[‘HTTP_AUTHORIZATION’]

Use your token variable to do whatever you want.

Happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *