table()->find($id); if ( ! is_null($session)) { return array( 'id' => $session->id, 'last_activity' => $session->last_activity, 'data' => unserialize($session->data) ); } } /** * Save a session. * * @param array $session * @return void */ public function save($session) { $this->delete($session['id']); $this->table()->insert(array( 'id' => $session['id'], 'last_activity' => $session['last_activity'], 'data' => serialize($session['data']) )); } /** * Delete a session by ID. * * @param string $id * @return void */ public function delete($id) { $this->table()->delete($id); } /** * Delete all expired sessions. * * @param int $expiration * @return void */ public function sweep($expiration) { $this->table()->where('last_activity', '<', $expiration)->delete(); } /** * Get a session database query. * * @return Query */ private function table() { return \System\DB::connection()->table(Config::get('session.table')); } }