[eluser]Neil_W[/eluser]
Hello,
Here is a class:
Code:
class Admin extends Controller {
function Admin()
{
parent::Controller();
$this->load->database('l4session');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->model('l4ac_article_model');
$this->load->model('l4ac_links_model');
}
function test1()
{
$this->session->set_userdata('logged_in',TRUE);
}
function test2()
{
$this->l4ac_links_model->set_deleted(1,1);
}
}
In my database.php file I have two groups, 'default' and another called 'l4session'.
As above I am setting l4session in constructor.
If I call test1 from the web browser then it uses the correct group, 'l4session'.
If I call test2 from the web browser then it uses whatever $active_group in database.php is and not 'l4session' as stated in the constructor.
Am I doing something wrong, or is there a bug somewhere?
btw, I know it's not working because I restricted privileges in mysql so can see what user it is trying to use.
I must add though, that I also do have 'database' loaded as an autoload - I couldn't find any other way in CodeIgniter to switch the active_group other than to call load->database and I use the default database group 99% of the time, hence why it's in autoload.
If I take it out of autoload then both functions work.
So I guess the real question is why does sessions use l4session but anything else uses the autoload?