【问题标题】:PHP Session in Kohana 3Kohana 3 中的 PHP 会话
【发布时间】:2010-10-27 16:02:08
【问题描述】:

所以我基本上无法在我的 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 在重定向之后为空。

不确定现在要尝试什么,我确实确保在 php.ini 中启用了 Sessions(我有很多其他应用程序,在其他框架或 CMS 下,当前已安装,我确信至少有一个他们使用会话)。目前我正在调查这个:http://forum.kohanaframework.org/discussion/3018/using-native-session-array/p1,虽然我怀疑这是这里的问题。

【问题讨论】:

    标签: php session kohana kohana-3


    【解决方案1】:

    不确定我在测试时的想法 - 但我解决了这个问题。我不得不猜测这里的问题是我自己的愚蠢。

    【讨论】:

    • 最后我的代码是正确的,错误与会话完全无关。
    • 你的“修复”是什么?因为我想我可能也有同样深刻的大脑放屁。我遇到了同样的问题。
    • 由于从未报告过“修复”:我今天遇到了完全相同的问题,我通过在 php.ini 中禁用 session.auto_start 来修复它。有时它似乎与 Kohana 的会话冲突。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多