所以我基本上无法在我的 Kohana 3 项目中使用任何类型的 session 。该问题的一些示例:
$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,在 session 中,在重定向之前具有正值,在其值为 0 之后。我也尝试过基本的 PHP session - 这可能在 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 中启用了 session (我在其他框架或 CMS 下目前安装了很多其他应用程序,并且我确信至少有一个他们使用 session )。目前我正在研究这个:http://forum.kohanaframework.org/discussion/3018/using-native-session-array/p1 ,尽管我怀疑这是这里的问题。
最佳答案
不确定我在测试时在想什么 - 但我解决了这个问题。我不得不猜测这里的问题是我自己的愚蠢。
关于Kohana 3 中的 PHP session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4035209/