Laravel 4:阅读由javascript设置的cookie [英] Laravel 4: reading cookies set by javascript

查看:59
本文介绍了Laravel 4:阅读由javascript设置的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用javascript设置cookie,如何使用Laravel 4读取它?

If I set a cookie with javascript, how would I read it using 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.

推荐答案

只需使用本机PHP命令来检索cookie:$_COOKIE['cookie'])

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

或者您可以通过AJAX命令设置cookie(而不是由JS自己设置)-并让Laravel代表JS设置由JS提供的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?

此链接可确认通过AJAX设置Cookie -只是它的一种变体.

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

这篇关于Laravel 4:阅读由javascript设置的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆