This is Thisclass controller where I originally set a session variable where $data is an array containing values fetched from the database
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class Thisclass extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
// The code for fetching values is here
$this->session->set_userdata("mysession",$data);
}
}//end class
?>
And this is the Anotherclass controller where I am trying to access that variable
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class Anotherclass extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
var_dump($this->session->userdata('mysession'));
}
}//end class
However, that var_dump returns null. I already checked the session library and it is included in the autoload.php. And I checked the index again and again and it maches. So, what might be the reason/s why I can't call that variable ? In the web server, it actually works. The session variable can be accessed in another controller and in this local copy, it doesn't seem to work. I already checked the necessary settings and it seems fine. Thanks you for your help..