i have renamed CI original Session.php library as Cookie.php,and than i made two personal classes into application/libraries and i load them by default into autoloader.php
1) Personal Library - Session.php
session_start();
class Session {
function set_data($key,$data)
{
if(!$key)
{ echo 'first param passed is null in session set_data';}
if(!$data)
{ echo 'second param passed is null in session set_data';}
if(isset($key) && isset($data))
{
if(isset($_SESSION[$key]))
{
unset($_SESSION[$key]);
}
return $_SESSION[$key] = $data;
}
function keep_data($key)
{
if(!$key)
{ echo 'first param passed is null in session keep_data';}
if(isset($_SESSION[$key]))
{
return htmlentities($_SESSION[$key]);
}
}
2) Personal Library - Settings.php
class Settings {
function setsitelanguage()
{
$CI =& get_instance();
if($CI->session->keep_data('lang'))
{
$CI->config->config['language'] = $CI->session->keep_data('lang');
}
else
{
$CI->config->config['language'] = "en";
}
}
than i have 2 controllers
1) Controller Home.php
class Home extends Controller {
function Home()
{
parent::Controller();
$this->settings->setsitelanguage();
}
function index()
{
$this->load->view('home/home_view');
}
function session()
{
echo $this->session->keep_data('lang');
}
}
2) Controller Auth.php
class Auth extends Controller {
function usersetlang()
{
$lang = $this->uri->segment(3);
return $this->session->set_data('lang',$lang);
}
}
as shown in http://mysite/index.php/home/session, i can retrieve my language site stored with session.php by auth.php
the only problem is that is not enough using global $_SESSION[] ,because if i try to retrieve data disabling my browser cookies $_SESSION[] data doesn’t appears !!!