From 534d5ca710840761d8f73e1d4f4018e7aa863356 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Mon, 2 Jun 2014 09:09:42 +0100 Subject: [PATCH] Changed cookie access to use CodeIgniter input class instead of direct access --- application/libraries/Aauth.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 5e95f52c..899581b0 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -46,7 +46,14 @@ public function __construct() { public function login($email, $pass, $remember = FALSE) { // remove cookies first - setcookie("user", "", time()-3600, '/'); + $cookie = array( + 'name' => 'user', + 'value' => '', + 'expire' => time()-3600, + 'path' => '/', + ); + + $this->CI->input->set_cookie($cookie); if( !valid_email($email) or !ctype_alnum($pass) or strlen($pass) < 5 or strlen($pass) > $this->config_vars['max'] ) { $this->error($this->config_vars['wrong']); @@ -95,7 +102,14 @@ public function login($email, $pass, $remember = FALSE) { $random_string = random_string('alnum', 16); $this->update_remember($row->id, $random_string, $remember_date ); - setcookie( 'user', $row->id . "-" . $random_string, time() + 99*999*999, '/'); + $cookie = array( + 'name' => 'user', + 'value' => $row->id . "-" . $random_string, + 'expire' => time() + 99*999*999, + 'path' => '/', + ); + + $this->CI->input->set_cookie($cookie); } // update last login @@ -143,10 +157,10 @@ public function is_loggedin() { {return true;} else{ - if( !array_key_exists('user', $_COOKIE) ){ + if( !$this->CI->input->cookie('user', TRUE) ){ return false; }else{ - $cookie = explode('-', $_COOKIE['user']); + $cookie = explode('-', $this->CI->input->cookie('user', TRUE)); if(!is_numeric( $cookie[0] ) or strlen($cookie[1]) < 13 ){return false;} else{ $query = $this->CI->db->where('id', $cookie[0]);