[eluser]Ngulo[/eluser]
Hi all guys
i'm trying to retrieve session data by my own library.
library is called Settings.php
and i put it to application/libraries as explained into user guide.
than i just put into a little bite of code like as shown:
Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Settings {
function setsitelanguage()
{
if($this->session->userdata('lang'))
{
$this->config->config['language'] = $this->session->userdata('lang');
}
else
{
$this->config->config['language'] = "en";
}
}
}//end class Settings.php
i loaded session library and this one library by default in the autoloader.php!
the problem is that i want to check the session userdata, into this library but i always receive this error:
Code:
Fatal error: Call to a member function userdata() on a non-object
the scheme is as shown:
1) first, i set userdata into my auth controller and redirect to home controller
Code:
class Auth extends Controller {
function usersetlang()
{
$lang = $this->uri->segment(3);
foreach($this->config->config['sitelangs'] as $data['lang'] )
{
if($lang == $data['lang'])
{
$this->session->set_userdata('lang',$lang);
redirect('home/home');
}
}
}
2) second , home controller try to configure site language by doing this
Code:
class Home extends Controller {
function Home()
{
parent::Controller();
$this->settings->setsitelanguage();
}
3) i take the error
i really can't find a solution, cause it seems that the session library is never loaded by autoloader.php , and than i can't access session object!!! :/
cansomeone help me?
really thanks