public static function getSession($userId, $sessionHash = '', &$dBAssertor = null, &$datastore = null, &$config = null) { $dBAssertor = $dBAssertor ? $dBAssertor : vB::getDbAssertor(); $datastore = $datastore ? $datastore : vB::getDatastore(); $config = $config ? $config : vB::getConfig(); $restoreSessionInfo = array('userid' => $userId); $session = new vB_Session_WebApi($dBAssertor, $datastore, $config, $sessionHash, $restoreSessionInfo); $session->set('userid', $userId); $session->fetch_userinfo(); return $session; }
/** * Creates a session object and attach it to the request. May reuse an existing session in the database. * * @param string $sessionhash -- the token given to the client for session handling. If the client has this token they * can use the session. * @param array $restoreSessionInfo -- Information to handle "remember me" logic. * * remembermetoken -- Token value for "remember me". Stored in the "password" cookie for legacy reasons. There are * so special values to indicate that we should reauthentic via a method other than the internal vB remember me * system. * * userid -- user we are remembering * * fbsr_{appid} (optional) -- Only valid if facebook is enabled, and only used if "remembermetoken" is "facebook". * * @return array * * sessionhash -- the session hash for the session created. This may be different from the passed sessionhash if that * session was expired or otherwise unusable. * * remembermetoken -- token for remembering the user. This should only be set if the user requests it (or if the * there is already a token present but the token changed). It is possible for this to change and if it * does and is not passed back to the client future attempts to "remember" the session (using the old value) will fail. */ public function createSessionNew($sessionhash, $restoreSessionInfo) { $session = vB_Session_WebApi::createSessionNew($sessionhash, $restoreSessionInfo); $this->setSession($session); return array('sessionhash' => $this->session->get('sessionhash'), 'remembermetoken' => $this->session->getRememberMeToken()); }