is_user_logged_in() always returning false

For those who has the problem with is_user_logged_in() in Wordpress returning only false, One of unexpected reason is the server is not getting Authorization header.

You might need to see all request headers by printing this code:

get all request headers in php

If you don't see Authorization header, then your problem is not the script, but the .htaccess file instead.

You gonna need to add these lines on your .httaccess file:

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
Show Comments