Welcome Guest, Not a member yet? Register   Sign In
How to start session globally?
#15

(11-04-2019, 10:48 AM)macruzgi Wrote: If I print those values on the current controller, it works correctly, but when evaluating them on another controller, it no longer exists.
Other controller:

PHP Code:
public function __construct(){
 
//parent::__construct();
 //establezco la zona horario par El Salvador
 
date_default_timezone_set('America/El_Salvador');
 
//comprobamos si el usuario está logueado
 
 
$this->sesion session();
 if(
$this->sesion->chequear != true)
 {
 
//si no estoy logueado que me envie a index
 
return redirect()->to(base_url());
 }
 
 
 } 

Any idea why that happens?

Does the above class extend BaseController? You MUST uncomment the line

PHP Code:
//parent::__construct(); 

Because if that does not run then the BaseController does not get to run this line

PHP Code:
//BaseController
$this->sesion  = \Config\Services::session(); 


In the example above you also do this

PHP Code:
$this->sesion session(); 

Don't do that!

$this->sesion should be set up by BaseController and so is ready for use.
Reply


Messages In This Thread
How to start session globally? - by happyape - 09-21-2018, 04:35 AM
RE: How to start session globally? - by sv3tli0 - 09-21-2018, 04:59 AM
RE: How to start session globally? - by happyape - 09-21-2018, 05:21 AM
RE: How to start session globally? - by happyape - 09-21-2018, 05:34 AM
RE: How to start session globally? - by sv3tli0 - 09-21-2018, 06:10 AM
RE: How to start session globally? - by happyape - 09-21-2018, 06:16 AM
RE: How to start session globally? - by kilishan - 09-21-2018, 06:16 AM
RE: How to start session globally? - by happyape - 09-21-2018, 06:58 AM
RE: How to start session globally? - by happyape - 09-21-2018, 07:36 AM
RE: How to start session globally? - by macruzgi - 11-04-2019, 10:48 AM
RE: How to start session globally? - by dave friend - 11-04-2019, 02:15 PM
RE: How to start session globally? - by macruzgi - 11-04-2019, 01:21 PM
RE: How to start session globally? - by kilishan - 09-21-2018, 09:21 AM
RE: How to start session globally? - by macruzgi - 11-04-2019, 01:29 PM
RE: How to start session globally? - by macruzgi - 11-04-2019, 03:05 PM
RE: How to start session globally? - by macruzgi - 11-05-2019, 07:51 AM
RE: How to start session globally? - by macruzgi - 11-08-2019, 04:17 PM
RE: How to start session globally? - by InsiteFX - 11-05-2019, 05:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB