function run() { /* * Set the "now" time * * It can either set to GMT or time(). The pref * is set in the config file. If the developer * is doing any sort of time localization they * might want to set the session time to GMT so * they can offset the "last_activity" and * "last_visit" times based on each user's locale. * */ if (strtolower($this->base->get('time_reference')) == 'gmt') { $now = time(); $this->now = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); if (strlen($this->now) < 10) { $this->now = time(); } } else { $this->now = time(); } /* * Set the session length * * If the session expiration is set to zero in * the config file we'll set the expiration * //two years from now. * 5 minutes from now * */ $expiration = $this->base->get('sess_expiration'); if (is_numeric($expiration)) { if ($expiration > 0) { $this->sess_length = $expiration; } else { $this->sess_length = 720; } } //check session validity // 1. check existance in table // 2. check expiration if ($this->session->stamp() + $this->sess_length < $this->now) { session_destroy(); $this->session = new Session(DB::instance()); } //run garbage collection if probability met $this->gc(); // delete old flashdata (from last request) $this->sweep_flash_data(); // mark all new flashdata as old (data will be deleted before next request) $this->mark_flash_data(); }
function create($user) { foreach ($user as $key => $value) { $this->mapper->{$key} = $value; } //todo DB::instance()->pdo()->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); try { $this->mapper->save(); } catch (\PDOException $e) { switch ($e->getMessage()) { default: throw new \Exception('failed to save new user'); } } return $this->mapper->cast(); }