Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MY_Controller extends CI_Controller {
- public function __construct() {
- parent::__construct();
- if(!$this->session->userdata('usuario')) {
- redirect('login');
- }
- }
- }
- if( $rs )
- {
- $this->session->set_userdata('usuario', $usuario);//usuario is a object
- //$this->load->view('painel');//it works
- redirect('painel', 'location');//it doesn't
- }
- else
- {
- $this->load->view('login', $data = array('mensagem'=>'Usuário ou senha inválidos.'));
- }
- echo $this->session->userdata('usuario')->usuario_nome; //it works
- only if I load->view('painel')
- Message: main() [function.main]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Usuario" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition
- class Events extends CI_Controller {
- // Constructor function
- public function __construct()
- {
- //load initial models and libraries that are needed for the controller
- parent::__construct();
- $this->load->library('auth');
- ...
- }
- ...
- }
- class Auth {
- var $CI = NULL;
- function Auth($props = array())
- {
- $this->CI =& get_instance();
- // Load additional libraries, helpers, etc.
- $this->CI->load->library('session');
- $this->CI->load->database();
- $this->CI->load->helper('url');
- @session_start();
- }
- ...
- }
- /*
- | -------------------------------------------------------------------
- | Auto-load Libraries
- | -------------------------------------------------------------------
- | These are the classes located in the system/libraries folder
- | or in your application/libraries folder.
- |
- | Prototype:
- |
- | $autoload['libraries'] = array('database', 'session', 'xmlrpc');
- */
- $autoload['libraries'] = array('database','session', 'encrypt');
Add Comment
Please, Sign In to add comment