Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4: reading cookies set by javascript

If I set a cookie with javascript, how would I read it using Laravel 4?

The reason I'm asking is that the docs say:

All cookies created by the Laravel framework are encrypted and signed 
with an authentication code, meaning they will be considered invalid 
if they have been changed by the client.
like image 360
duality_ Avatar asked Feb 20 '13 08:02

duality_


1 Answers

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.

like image 136
Laurence Avatar answered Sep 21 '22 07:09

Laurence