Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mazinoukah's avatar

authentication not working when request is ajax

I transfered my site to a shared hosting server, but then i discovered that my ajax calls where not working anymore, it was giving me CORS errors so i updated my .htacess file with : Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Credentials true Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type, X-Auth-Token, Authorization" Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS" then that fix the CORS error but however in my controller method that is handling that request , i cant retrieve the logged in user. i have tried using Auth::id() and Request::user() but it keeps returning null . please how can i fix this ?

0 likes
1 reply
ehtasham's avatar

Check file permissions, I think session storing issue. Give 777 permission to storage directory.

Please or to participate in this conversation.