Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
improved wording and structure of sentences
Source Link

Seeing youyour configuration, maybe you have the same problem that iI had, i didn't. I wasn't using Auth, but i'm using sessions and get nullgot null everytime, and i. I solved it by changing this:

header('Access-Control-Allow-Origin: *'); ... header('Access-Control-Allow-Credentials: true'); 

forto this:

header('Access-Control-Allow-Origin: http://localhost:9000'); ... header('Access-Control-Allow-Credentials: true'); 

And theThe reason that iI found is that when you use the credentials it needs to specify the Originorigin for security purposes, and aboutfor the ajaxAJAX request it needs to specify the with credentials too, too. I use angularAngular and iI did this with $httpProvider.defaults.withCredentials=true; and i, but I really don't know thisthe corresponding instruction for jqueryjQuery, but iI hope you foundcan find it. Check

Check the headers of the request and responses with your favourite debugger (Firebug for me) they. They should have a cookie attribute (it contains something with "laravel", "token", etc.) that the second time should be equal to the first response header. Regards.

Seeing you configuration maybe you have the same problem that i had, i didn't using Auth, but i'm using sessions and get null everytime, and i solved changing this:

header('Access-Control-Allow-Origin: *'); ... header('Access-Control-Allow-Credentials: true'); 

for this:

header('Access-Control-Allow-Origin: http://localhost:9000'); ... header('Access-Control-Allow-Credentials: true'); 

And the reason that i found is that when you use the credentials it needs to specify the Origin for security purposes, and about the ajax request it needs to specify the with credentials too, I use angular and i did this with $httpProvider.defaults.withCredentials=true; and i really don't know this instruction for jquery, but i hope you found it. Check the headers of the request and responses with your favourite debugger (Firebug for me) they should have a cookie attribute (it contains something with "laravel", "token", etc.) that the second time should be equal to the first response header. Regards.

Seeing your configuration, maybe you have the same problem that I had. I wasn't using Auth, but sessions and got null everytime. I solved it by changing this:

header('Access-Control-Allow-Origin: *'); ... header('Access-Control-Allow-Credentials: true'); 

to this:

header('Access-Control-Allow-Origin: http://localhost:9000'); ... header('Access-Control-Allow-Credentials: true'); 

The reason that I found is that when you use the credentials it needs to specify the origin for security purposes, and for the AJAX request it needs to specify the credentials, too. I use Angular and I did this with $httpProvider.defaults.withCredentials=true;, but I really don't know the corresponding instruction for jQuery, but I hope you can find it.

Check the headers of the request and responses with your favourite debugger (Firebug for me). They should have a cookie attribute (it contains something with "laravel", "token", etc.) that the second time should be equal to the first response header.

Source Link

Seeing you configuration maybe you have the same problem that i had, i didn't using Auth, but i'm using sessions and get null everytime, and i solved changing this:

header('Access-Control-Allow-Origin: *'); ... header('Access-Control-Allow-Credentials: true'); 

for this:

header('Access-Control-Allow-Origin: http://localhost:9000'); ... header('Access-Control-Allow-Credentials: true'); 

And the reason that i found is that when you use the credentials it needs to specify the Origin for security purposes, and about the ajax request it needs to specify the with credentials too, I use angular and i did this with $httpProvider.defaults.withCredentials=true; and i really don't know this instruction for jquery, but i hope you found it. Check the headers of the request and responses with your favourite debugger (Firebug for me) they should have a cookie attribute (it contains something with "laravel", "token", etc.) that the second time should be equal to the first response header. Regards.