/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // initialize the session $this->data = array(); $this->keys = array(); $this->flash = array(); // get the session cookie $payload = $this->_get_cookie(); // validate it if ($payload === false or $force) { // not a valid cookie, or a forced session reset } elseif (!isset($payload[0]) or !is_array($payload[0])) { // not a valid cookie payload } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) { // session has expired } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) { // IP address doesn't match } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) { // user agent doesn't match } else { // session is valid, retrieve the payload if (isset($payload[0]) and is_array($payload[0])) { $this->keys = $payload[0]; } if (isset($payload[1]) and is_array($payload[1])) { $this->data = $payload[1]; } if (isset($payload[2]) and is_array($payload[2])) { $this->flash = $payload[2]; } } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return void */ public function read($force = false) { // get the session cookie $payload = $this->_get_cookie(); // if no session cookie was present, create it if ($payload === false or $force) { $this->create(); } if (isset($payload[0])) { $this->data = $payload[0]; } if (isset($payload[1])) { $this->flash = $payload[1]; } parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // get the session cookie $payload = $this->_get_cookie(); // if no session cookie was present, initialize a new session if ($payload === false or $force) { $this->data = array(); $this->keys = array(); return $this; } if (isset($payload[0])) { $this->data = $payload[0]; } if (isset($payload[1])) { $this->flash = $payload[1]; } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return void */ public function read($force = false) { // get the session cookie $cookie = $this->_get_cookie(); // if no session cookie was present, create it if ($cookie === false or $force) { $this->create(); } // read the session file $payload = $this->_read_redis($this->keys['session_id']); if ($payload === false) { // try to find the previous one $payload = $this->_read_redis($this->keys['previous_id']); if ($payload === false) { // cookie present, but session record missing. force creation of a new session $this->read(true); return; } } // unpack the payload $payload = $this->_unserialize($payload); // session referral? if (isset($payload['rotated_session_id'])) { $payload = $this->_read_redis($payload['rotated_session_id']); if ($payload === false) { // cookie present, but session record missing. force creation of a new session $this->read(true); return; } else { // update the session $this->keys['previous_id'] = $this->keys['session_id']; $this->keys['session_id'] = $payload['rotated_session_id']; // unpack the payload $payload = $this->_unserialize($payload); } } if (isset($payload[0])) { $this->data = $payload[0]; } if (isset($payload[1])) { $this->flash = $payload[1]; } parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // initialize the session $this->data = array(); $this->keys = array(); $this->flash = array(); // get the session cookie $payload = $this->_get_cookie(); // validate it if ($force) { // a forced session reset } elseif ($payload === false) { // no cookie found } elseif (!isset($payload[0]) or !is_array($payload[0])) { logger('DEBUG', 'Error: not a valid cookie payload!'); } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) { logger('DEBUG', 'Error: session id has expired!'); } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) { logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!'); } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) { logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!'); } else { // session is valid, retrieve the payload if (isset($payload[0]) and is_array($payload[0])) { $this->keys = $payload[0]; } if (isset($payload[1]) and is_array($payload[1])) { $this->data = $payload[1]; } if (isset($payload[2]) and is_array($payload[2])) { $this->flash = $payload[2]; } } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // initialize the session $this->data = array(); $this->keys = array(); $this->flash = array(); // get the session cookie $cookie = $this->_get_cookie(); // if a cookie was present, find the session record if ($cookie and !$force and isset($cookie[0])) { // read the session file $payload = $this->_read_redis($cookie[0]); if ($payload === false) { // cookie present, but session record missing. force creation of a new session return $this->read(true); } // unpack the payload $payload = $this->_unserialize($payload); // session referral? if (isset($payload['rotated_session_id'])) { $payload = $this->_read_redis($payload['rotated_session_id']); if ($payload === false) { // cookie present, but session record missing. force creation of a new session return $this->read(true); } // unpack the payload $payload = $this->_unserialize($payload); } if (!isset($payload[0]) or !is_array($payload[0])) { // not a valid cookie payload } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) { // session has expired } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) { // IP address doesn't match } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) { // user agent doesn't match } else { // session is valid, retrieve the rest of the payload if (isset($payload[0]) and is_array($payload[0])) { $this->keys = $payload[0]; } if (isset($payload[1]) and is_array($payload[1])) { $this->data = $payload[1]; } if (isset($payload[2]) and is_array($payload[2])) { $this->flash = $payload[2]; } } } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // initialize the session $this->data = array(); $this->keys = array(); $this->flash = array(); $this->record = null; // get the session cookie $cookie = $this->_get_cookie(); // if a cookie was present, find the session record if ($cookie and !$force and isset($cookie[0])) { // read the session record $this->record = \DB::select()->where('session_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // try to find the session on previous id $this->record = \DB::select()->where('previous_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // cookie present, but session record missing. force creation of a new session logger('DEBUG', 'Error: Session cookie with ID "' . $cookie[0] . '" present but corresponding record is missing'); return $this->read(true); } } if (!isset($payload[0]) or !is_array($payload[0])) { logger('DEBUG', 'Error: not a valid db session payload!'); } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) { logger('DEBUG', 'Error: session id has expired!'); } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) { logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!'); } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) { logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!'); } else { // session is valid, retrieve the payload if (isset($payload[0]) and is_array($payload[0])) { $this->keys = $payload[0]; } if (isset($payload[1]) and is_array($payload[1])) { $this->data = $payload[1]; } if (isset($payload[2]) and is_array($payload[2])) { $this->flash = $payload[2]; } } } return parent::read(); }
/** * read the session * * @access public * @param * boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // initialize the session $this->data = array(); $this->keys = array(); $this->flash = array(); $this->record = null; // get the session cookie $cookie = $this->_get_cookie(); // if a cookie was present, find the session record if ($cookie and !$force and isset($cookie[0])) { // read the session record $this->record = \DB::select()->where('session_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // try to find the session on previous id $this->record = \DB::select()->where('previous_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // cookie present, but session record missing. force creation of a new session return $this->read(true); } } if (!isset($payload[0]) or !is_array($payload[0])) { // not a valid cookie payload } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) { // session has expired } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) { // IP address doesn't match } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) { // user agent doesn't match } else { // session is valid, retrieve the payload if (isset($payload[0]) and is_array($payload[0])) { $this->keys = $payload[0]; } if (isset($payload[1]) and is_array($payload[1])) { $this->data = $payload[1]; } if (isset($payload[2]) and is_array($payload[2])) { $this->flash = $payload[2]; } } } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return Fuel\Core\Session_Driver */ public function read($force = false) { // get the session cookie $cookie = $this->_get_cookie(); // if no session cookie was present, initialize a new session if ($cookie === false or $force) { $this->data = array(); $this->keys = array(); } else { // read the session record $this->record = \DB::select()->where('session_id', '=', $this->keys['session_id'])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // try to find the session on previous id $this->record = \DB::select()->where('previous_id', '=', $this->keys['session_id'])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { // previous id used, correctly set session id so it wont be overwritten with previous id. $this->keys['session_id'] = $this->record->get('session_id'); $payload = $this->_unserialize($this->record->get('payload')); } else { // cookie present, but session record missing. force creation of a new session return $this->read(true); } } if (isset($payload[0])) { $this->data = $payload[0]; } if (isset($payload[1])) { $this->flash = $payload[1]; } } return parent::read(); }
/** * read the session * * @access public * @param boolean, set to true if we want to force a new session to be created * @return void */ public function read($force = false) { // get the session cookie $cookie = $this->_get_cookie(); // if no session cookie was present, create it if ($cookie === false or $force) { $this->create(); } // read the session record $this->record = \DB::select()->where('session_id', '=', $this->keys['session_id'])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // try to find the session on previous id $this->record = \DB::select()->where('previous_id', '=', $this->keys['session_id'])->from($this->config['table'])->execute($this->config['database']); // record found? if ($this->record->count()) { $payload = $this->_unserialize($this->record->get('payload')); } else { // cookie present, but session record missing. force creation of a new session $this->read(true); return; } } if (isset($payload[0])) $this->data = $payload[0]; if (isset($payload[1])) $this->flash = $payload[1]; parent::read(); }