如何在kohana应用程序之外获取kohana会话数据? [英] How to get kohana session data outside kohana application?

查看:45
本文介绍了如何在kohana应用程序之外获取kohana会话数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 kohana 应用程序之外获取 kohana 会话数据.我的意思是说我想在一个不是 kohana 页面的静态文件中获取会话数据.

I want to get the kohana session data outside the kohana application. I mean to say that i want to get the session data in a static file which is not a kohana page.

推荐答案

我尝试了很多方法,终于找到了答案,

I have tried many things and atlast i have found the answer,

在您的控制器类中,在 kohana 会话实例之前获取本机会话 ID 并存储它.现在关闭本机会话并通过将会话 id 作为参数传递来启动 kohana 会话.

In your controller class, get the native session id before kohana session instance and store it. Now close the native session and initiate kohana session by passing the session id as an argument.

    session_start();    
    // Store session id and close the session
    $sessionId = session_id();
    session_write_close();

    // Then we can restore the session by using the session id 
    // and the Session class from Kohana
    Session::Instance(Session::$default, $sessionId);

现在您可以访问 kohana 应用程序内的会话.

Now you can access the session inside the kohana application.

这篇关于如何在kohana应用程序之外获取kohana会话数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆