Kohana 3 中的 PHP 会话
所以我基本上无法在我的 Kohana 3 项目中使用任何类型的会话。这个问题的几个例子:
$session = Session::instance();
$session->set('customer_id', $customer->id);
$this->request->redirect('controller/action');
//At the start of the redirected action
$session = Session::instance();
$customer_id = $session->get('customer_id');
$customer_id,在会话中,在重定向之前有一个正值,在它的值为 0 之后。我也尝试过基本的 PHP 会话 - 这可能在 Kohana 中被禁用 - 我没有知道。没想到,因为我们仍然可以使用$_GET和$_POST。
session_start();
$_SESSION['customer_id'] = $customer->id;
//At the start of the redirected action
session_start();
$customer_id = $_SESSION['customer_id'];
与之前的场景相同,只是现在重定向后的 $customer_id 为 null。
不知道现在要尝试什么,我确实确保在 php.ini 中启用了会话(我在其他框架或 CMS 下目前安装了很多其他应用程序,并且我确信其中至少有一个使用会话)。目前我正在研究这个: http://forum.kohanaframework .org/discussion/3018/using-native-session-array/p1 ,尽管我怀疑这是这里的问题。
So I'm basically unable to use any kind of session in my Kohana 3 project. A few example of the issue :
$session = Session::instance();
$session->set('customer_id', $customer->id);
$this->request->redirect('controller/action');
//At the start of the redirected action
$session = Session::instance();
$customer_id = $session->get('customer_id');
$customer_id, in the session, has a positive value before the redirect, after it has a value of 0. I also tried with the basic PHP session - which may be disabled in Kohana - I don't know. Didn't thought so, since we can still use $_GET and $_POST.
session_start();
$_SESSION['customer_id'] = $customer->id;
//At the start of the redirected action
session_start();
$customer_id = $_SESSION['customer_id'];
Same scenario as before, except that now the $customer_id, after the redirect, is null.
Not sure what to try right now, I did make sure Sessions were enable in php.ini (I have quite a bunch of others application, under other framework or CMS, currently installed, and I'm convinced at least one of them use sessions). Currently I'm looking into this : http://forum.kohanaframework.org/discussion/3018/using-native-session-array/p1 , though I doubt it's the issue here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定当我测试这个时我在想什么 - 但我解决了这个问题。我不得不猜测这里的问题是我自己的愚蠢。
Not sure what I was thinking when I was testing this - but I resolved this. I'd have to guess the issue here was my own profound stupidity.