Kohana 2.x恢复会议

时间:2011-03-25 19:09:00

标签: php session kohana

在Kohana 2.x中有没有办法恢复会话,知道它的ID?

1 个答案:

答案 0 :(得分:2)

来自Kohana 2. *存储库:Line 113 of system/libraries/Session.phpSession::instance允许传入ID。

/**
 * Singleton instance of Session.
 *
 * ##### Example
 *
 *     // This is the idiomatic and preferred method of starting a session
 *     $session = Session::instance();
 *
 * @param string Force a specific session_id
 */
public static function instance($session_id = NULL)
{
    if (Session::$instance == NULL)
    {
        // Create a new instance
        new Session($session_id);
    }
    elseif( ! is_null($session_id) AND $session_id != session_id() )
    {
        throw new Kohana_Exception('A session (SID: :session:) is already open, cannot open the specified session (SID: :new_session:).', array(':session:' => session_id(), ':new_session:' => $session_id));
    }

    return Session::$instance;
}