我想在kohana应用程序之外获取kohana会话数据。我的意思是,我想要在一个静态文件中获取会话数据,该文件不是kohana页面。
发布于 2013-07-16 20:17:10
我尝试了很多方法,终于找到了答案,
在您的控制器类中,在kohana会话实例之前获取本机会话id并存储它。现在关闭本机会话,并通过传递会话id作为参数来启动kohana会话。
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应用程序中访问会话了。
发布于 2013-05-18 19:26:21
session_name('kohana'); //Your session name
print_r($_SESSION);通过在APPPATH/config/session.php上创建会话配置文件,可以将配置设置应用于每个会话适配器。以下示例配置文件定义了每个适配器的所有设置:
!!与cookies一样,“生命周期”设置为"0“意味着会话将在浏览器关闭时过期。
return array(
'native' => array(
'name' => 'session_name',
'lifetime' => 43200,
),
'cookie' => array(
'name' => 'cookie_name',
'encrypted' => TRUE,
'lifetime' => 43200,
),
'database' => array(
'name' => 'cookie_name',
'encrypted' => TRUE,
'lifetime' => 43200,
'group' => 'default',
'table' => 'table_name',
'columns' => array(
'session_id' => 'session_id',
'last_active' => 'last_active',
'contents' => 'contents'
),
'gc' => 500,
),
);https://stackoverflow.com/questions/16623615
复制相似问题