php - Undefined property: CI::$session -


i having trouble loading model on login page. has problem sessions on here. have security class helper $key part of it. think session error says.

i think have set num rows correct not sure if may cause of it.

a php error encountered severity: notice message: undefined property: ci::$session filename: core/model.php line number: 51 

model

<?php  if ( ! defined('basepath')) exit('no direct script access allowed'); class users_model extends ci_model {      private $user_id;     private $username;     private $permission = array();      public function __construct() {          if (isset($this->session->userdata['user_id'])) {             $user_query = $this->db->query("select * " . $this->input->post('dbprefix') . "user user_id = '" . (int)$this->session->userdata['user_id'] . "' , status = '1'");              if ($user_query->num_rows) {                 $this->user_id = $user_query->row['user_id'];                 $this->username = $user_query->row['username'];                  $this->db->query("update " . $this->input->post('dbprefix') . "user set ip = '" . $this->db->escape($this->input->server['remote_addr']) . "' user_id = '" . (int)$this->session->userdata['user_id'] . "'");                  $user_group_query = $this->db->query("select permission " . $this->input->post('dbprefix'). "user_group user_group_id = '" . (int)$user_query->row['user_group_id'] . "'");                  $permissions = unserialize($user_group_query->row['permission']);                  if (is_array($permissions)) {                     foreach ($permissions $key => $value) {                         $this->permission[$key] = $value;                     }                 }             } else {                 $this->logout();             }         }     }      public function login($username, $password) {         $user_query = $this->db->query("select * " . $this->input->post('dbprefix') . "user username = '" . $this->db->escape($username) . "' , (password = sha1(concat(salt, sha1(concat(salt, sha1('" . $this->db->escape($password) . "'))))) or password = '" . $this->db->escape(md5($password)) . "') , status = '1'");          if ($user_query->num_rows) {             $this->session->userdata['user_id'] = $user_query->row['user_id'];              $this->user_id = $user_query->row['user_id'];             $this->username = $user_query->row['username'];                       $user_group_query = $this->db->query("select permission " . $this->input->post('dbprefix') . "user_group user_group_id = '" . (int)$user_query->row['user_group_id'] . "'");              $permissions = unserialize($user_group_query->row['permission']);              if (is_array($permissions)) {                 foreach ($permissions $key => $value) {                     $this->permission[$key] = $value;                 }             }              return true;         } else {             return false;         }     } 

if using session in code make sure autoload in config.php file setting encryption key. if don't autoload can load using $this->load->library('session'). must set encryption key in order autoload or load session in controller functions.

detailed information here. working sessions in codeigniter


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -