cakephp 会话 ID 为空
当我执行以下操作时,会话 ID 为空: pr($this->Session);
我收到:
SessionComponent Object
(
[__active] => 1
[__bare] => 0
[valid] => 1
[error] =>
[_userAgent] => 5343528de22b8a6d25e7fd391692c911
[path] => /profiles
[lastError] =>
[security] => medium
[time] => 800-452-3639
[sessionTime] => 800-452-3639
[cookieLifeTime] => 720000
[watchKeys] => Array
(
)
[id] =>
[host] => xyz.org
[timeout] =>
[enabled] => 1
)
如何启用会话 ID 或创建会话 ID?
The session id is empty when I do: pr($this->Session);
I receive :
SessionComponent Object
(
[__active] => 1
[__bare] => 0
[valid] => 1
[error] =>
[_userAgent] => 5343528de22b8a6d25e7fd391692c911
[path] => /profiles
[lastError] =>
[security] => medium
[time] => 800-452-3639
[sessionTime] => 800-452-3639
[cookieLifeTime] => 720000
[watchKeys] => Array
(
)
[id] =>
[host] => xyz.org
[timeout] =>
[enabled] => 1
)
How do I either enable the session id or make the session id?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您确实需要会话 ID,则需要启动会话。在之前的过滤器中尝试一下:
然后当您
pr($this->Session->id());
时,您将看到新的会话 ID。If you really want a session id, you need to start the session. Try this in your before filter:
Then when you
pr($this->Session->id());
you will see the new session id.它由 Cake 被动处理 - 您不需要设置它。只需根据需要调用 read()、write() 即可。
It's passively taken care of by Cake - you don't need to set it. Just make calls to read(), write() as needed.
只需使用
//在控制器中 。不需要 start() 或其他东西。 Cakephp(在 2.7 中测试)会自动为您提供它。
Just use
in controller. There is no need to start() or something else. Cakephp (tested in 2.7) automatically makes it available for you.