Why Laravel5.4 $request->cookie('key') is empty when PHP global var $_COOKIE has cookies

Viewed 1327

I am trying to read the cookies in Laravel5.4. So I get the cookies after successful validation with third party Authorization server. I am not making the cookies in laravel5.4, but I am reading the cookie value send to me from view/frontend. I can see the values of cookies in Chrome debugger environment as well as from PHP global variable $_COOKIE. They are all set correctly.

However, when I tried to read the same cookie using $request->cookie('key') from controller method... it shows nothing. I also tried Cookie facade to read the value and still nothing. This controller is handling a redirect route which is called by the third party oauth server and this server when it redirects to my URL, it also sets the cookies.

Am I not setting this redirect url route correctly in web.php file in Laravel5.4? This is how it is defined in web.php as below:

Route::get('login/okta/callback', 'Auth\LoginController@handleProviderCallback');

The request object is empty when I dumped the content but $_COOKIE has the data.

1 Answers
Related