質問

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,

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);

Now you can access the session inside the kohana application.

他のヒント

session_name('kohana'); //Your session name   
print_r($_SESSION);

You can apply configuration settings to each of the session adapters by creating a session config file at APPPATH/config/session.php. The following sample configuration file defines all the settings for each adapter:

[!!] As with cookies, a "lifetime" setting of "0" means that the session will expire when the browser is closed.

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,
    ),
);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top