Laravel 4: reading cookies set by javascript Laravel 4: reading cookies set by javascript laravel laravel

Laravel 4: reading cookies set by javascript


Just use the native PHP command to retrieve cookies: $_COOKIE['cookie'])

Or perhaps you can set the cookie via an AJAX command (rather than JS doing it itself) - and have Laravel set the cookie supplied by JS on its behalf?

This link confirms setting cookies via AJAX - it will just be a variation of that.


In Laravel 5.6 (and maybe earlier versions too):

Specify the cookie name in the $except array within App\Http\Middleware\EncryptCookies.php.

It tells Laravel that those cookies aren't encrypted (and therefore don't need to be decrypted when read).

(P.S. Thanks to https://github.com/laravel/laravel/pull/460#issuecomment-377537771)