From 221b58a8d91e779e4be184257da857c36a0b87e3 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 12 Jul 2012 01:33:58 +0200 Subject: Store userid in session We don't really have to hit the db here every time. Signed-off-by: Florian Pritz --- application/models/muser.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'application/models') diff --git a/application/models/muser.php b/application/models/muser.php index a93865fd4..d123c8701 100644 --- a/application/models/muser.php +++ b/application/models/muser.php @@ -33,6 +33,7 @@ class Muser extends CI_Model { if (crypt($password, $query["password"]) === $query["password"]) { $this->session->set_userdata('logged_in', true); $this->session->set_userdata('username', $username); + $this->session->set_userdata('userid', $query["id"]); return true; } else { return false; @@ -61,12 +62,7 @@ class Muser extends CI_Model { return 0; } - $query = $this->db->query(" - SELECT id - FROM users - WHERE username = ? - ", array($this->get_username()))->row_array(); - return $query["id"]; + return $this->session->userdata("userid"); } function require_access() -- cgit v1.2.3-24-g4f1b