Welcome Guest, Not a member yet? Register   Sign In
Avoid validate session in each method of controller
#2

[eluser]sneakyimp[/eluser]
I recommend that you write a class to extend CI_Controller and in the constructor of this class, you put your session check. Something like this:

Code:
/**
* A controller specific my web applications that will force
* authentication before granting access
*/
class My_Controller extends CI_Controller {
function __construct() {
  parent::__construct();
  
  // check login here
  if (!$this->native_session->get(‘IdUsuario’)){
   redirect(‘acceso_usuario’, ‘refresh’);
  }
} // __construct()

} // class My_Controller

Then instead of having your controllers extend CI_Controller, have them extend My_Controller. You may have a bit of trouble getting code igniter to find your class. You may also need to work on that a little to make sure you've loaded your native_session module.


Messages In This Thread
Avoid validate session in each method of controller - by El Forum - 05-01-2014, 08:13 AM
Avoid validate session in each method of controller - by El Forum - 05-01-2014, 05:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB