【发布时间】:2014-11-27 06:16:03
【问题描述】:
我有这样的 laravel 控制器:
public function postSessionTopic() {
$article_id = Input::get('article_id', 0);
$comment_id = Input::get('comment_id', 0);
\Session::set('page_topic_id', $article_id);
\Session::set('page_comment_id', $comment_id);
\\comment - I have tried \Session::put too, but that doesn't change anything
}
当用户点击一篇文章时,我会使用它。我在这个控制器中打印出我的会话变量,一切看起来都很好。但在那之后我刷新了我的页面,在那里我从会话中读取值,有时它会加载旧值或不加载任何东西。我不明白为什么,因为在控制器中我可以看到,保存了正确的值!
在我的页面中,我得到这样的值:
\Session::get('page_topic_id', 0)
【问题讨论】:
-
检查您的会话 cookie 域,例如,如果您的 cookie 保存到 www.example.org 并且您访问 example.loc,您将不会在两者中访问相同的会话
-
域总是相同的
标签: session laravel laravel-4 controller