• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class 'CI_Controller' not found

#1
I try to call in system/core/Common.php next:
Code:
$ci =& get_instance();
$ci->load->library('session');
$userdetails = $ci->session->userdata('userdetails');

But I getting a fatal error: 
Code:
Class 'CI_Controller' not found in /system/core/CodeIgniter.php on line 233
 
I thought to connect directly:
Code:
require BASEPATH.'core/Controller.php';

But I getting other error:
Code:
Fatal error: Cannot redeclare class CI_Controller in /system/core/Controller.php on line 30


How I can getting session's data in Common.php ?
Reply

#2
Never modify any files in the system folder or subfolders.
Only create or modify files in the application folder and it's subfolders.
The use the session library, autoload it in application/config/autoload.php or just load it into one of your controllers.

The $ci =& get_instance(); method is only necessary in libraries, not in controllers.
In a controller, you must use the $this object to refer to the controller's class.
Example:
PHP Code:
$this->load->library('session');
$this->session->userdetails 'test';
echo 
$this->session->userdetails;
unset(
$_SESSION['userdetails']); 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.