如果我用javascript设置cookie,我如何用Laravel 4读取它?
我问的原因是医生说:
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.发布于 2013-02-20 19:47:31
只需使用原生PHP命令来检索cookie:$_COOKIE['cookie'])
或者,您可以通过AJAX命令设置cookie (而不是JS自己设置)-让Laravel代表其设置JS提供的cookie?
This link confirms setting cookies via AJAX -它将只是它的一个变体。
发布于 2018-03-31 01:10:54
在Laravel 5.6 (可能还有更早的版本)中:
在App\Http\Middleware\EncryptCookies.php内的$except数组中指定cookie名称。
它告诉Laravel这些cookie没有加密(因此在读取时不需要解密)。
(附言:感谢https://github.com/laravel/laravel/pull/460#issuecomment-377537771)
https://stackoverflow.com/questions/14975751
复制相似问题