简体   繁体   English

Kohana 3中的PHP会话

[英]PHP Session in Kohana 3

So I'm basically unable to use any kind of session in my Kohana 3 project. 因此,我基本上无法在Kohana 3项目中使用任何类型的会话。 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. 在会话中,$ customer_id在重定向之前具有正值,在其值为0之后。我还尝试了基本的PHP会话-可能在Kohana中禁用了-我不知道。 Didn't thought so, since we can still use $_GET and $_POST. 没想到,因为我们仍然可以使用$ _GET和$ _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. 除了在重定向之后现在$ customer_id为空之外,其他情况与之前相同。

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). 不知道现在要尝试什么,我确实确保在php.ini中启用了Sessions(我在当前安装的其他框架或CMS下有很多其他应用程序,而且我确信其中至少有一个使用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. 目前,我正在研究以下内容: http : //forum.kohanaframework.org/discussion/3018/using-native-session-array/p1 ,尽管我怀疑这是问题所在。

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. 我不得不猜测这里的问题是我自己的愚蠢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM