[eluser]the jan[/eluser]
I'm currently stuck on a problem. I need to access session data from within MY_Language.php but I can't access get_instance().
Here is my code:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Language extends CI_Language {
function MY_Language()
{
parent::CI_Language();
global $CFG;
$language = $this->languageChoice();
$CFG->set_item('language', $language);
}
function languageChoice()
{
$CI =& get_instance();
return $CI->session->userdata('language');
}
}
?>
But I keep getting "Fatal error: Call to undefined function get_instance() in /../app/libraries/MY_Language.php on line 40"
How can I get this solved? I need to select the language file based on the session data of a user.
I also tried tried extending the controller but even though the config item is changed ( I see that when I echo the config variable in the actual controller) it still gets the data from the wrong language file:
Code:
function My_Controller()
{
parent::Controller();
$this->obj =& get_instance();
if($this->obj->session->userdata('language'))
{
$this->config->set_item('language', $this->obj->session->userdata('language'));
}
else
{
$this->config->set_item('language', 'german');
}
}
Basicly I just need to choose the language file based on the data from a session variable.
Any help would be greatly appreciated.
Jan