Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. class MY_Controller extends CI_Controller {
  2.  
  3. public function __construct() {
  4. parent::__construct();
  5. if(!$this->session->userdata('usuario')) {
  6. redirect('login');
  7. }
  8. }
  9.  
  10. }
  11.  
  12. if( $rs )
  13. {
  14.  
  15. $this->session->set_userdata('usuario', $usuario);//usuario is a object
  16. //$this->load->view('painel');//it works
  17. redirect('painel', 'location');//it doesn't
  18. }
  19. else
  20. {
  21. $this->load->view('login', $data = array('mensagem'=>'Usuário ou senha inválidos.'));
  22. }
  23.  
  24. echo $this->session->userdata('usuario')->usuario_nome; //it works
  25. only if I load->view('painel')
  26.  
  27. 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
  28.  
  29. class Events extends CI_Controller {
  30. // Constructor function
  31. public function __construct()
  32. {
  33. //load initial models and libraries that are needed for the controller
  34. parent::__construct();
  35. $this->load->library('auth');
  36. ...
  37. }
  38. ...
  39. }
  40.  
  41. class Auth {
  42. var $CI = NULL;
  43.  
  44. function Auth($props = array())
  45. {
  46. $this->CI =& get_instance();
  47.  
  48. // Load additional libraries, helpers, etc.
  49. $this->CI->load->library('session');
  50. $this->CI->load->database();
  51. $this->CI->load->helper('url');
  52. @session_start();
  53. }
  54. ...
  55. }
  56.  
  57. /*
  58. | -------------------------------------------------------------------
  59. | Auto-load Libraries
  60. | -------------------------------------------------------------------
  61. | These are the classes located in the system/libraries folder
  62. | or in your application/libraries folder.
  63. |
  64. | Prototype:
  65. |
  66. | $autoload['libraries'] = array('database', 'session', 'xmlrpc');
  67. */
  68.  
  69. $autoload['libraries'] = array('database','session', 'encrypt');
Add Comment
Please, Sign In to add comment