Kohana 3 中的 PHP 会话

发布于 2024-09-29 04:26:38 字数 988 浏览 8 评论 0原文

所以我基本上无法在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城旧梦 2024-10-06 04:26:38

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文