【问题标题】:Kohana 2.x restoring sessionKohana 2.x 恢复会话
【发布时间】:2011-03-25 19:08:59
【问题描述】:

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

【问题讨论】:

    标签: php session kohana


    【解决方案1】:

    来自 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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-13
      • 2020-05-21
      • 1970-01-01
      • 2023-04-02
      • 2020-12-19
      • 2023-01-15
      相关资源
      最近更新 更多