If authentication is never logging you in, then your HTTP server is not forwarding Authentication header to PHP.

If this is the case, then you need to edit your configuration file, to forward the HTTP_AUTHORIZATION header.

For example if you have cPanel and easyApache, then you can do it like this:

Locate file: /etc/apache2/conf.d/userdata/authentication.conf (if the file is missing, then create it)

Add following contents:

<IfModule mod_rewrite.c>

   RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

</IfModule>



Now restart Apache and authentication should start working.

Source:

https://documentation.cpanel.net/display/EA4/Modify+Apache+Virtual+Hosts+with+Include+Files

https://stackoverflow.com/questions/26475885/authorization-header-missing-in-php-post-request