[eluser]joao.sobrinho[/eluser]
Hi.
I'm trying to use session data in some language files.
So far, I managed to use it like this:
the start of a language file:
Code:
$CI_session = &load;_class('Session');
$CI_session->keep_all_flashdata();
if(!isset($CI_session->userdata['var'])){
$CI_session->userdata['var1_label'] = 'bla bla';
$CI_session->userdata['var2_label'] = 'bla bla';
}
I use that if, to be sure that the data really exists for the rest of the file.
I changed the Session Class by adding this function to keep the flashdata
Code:
function keep_all_flashdata()
{
$userdata = $this->all_userdata();
foreach ($userdata as $name => $value)
{
$parts = explode(':old:', $name);
if (is_array($parts) && count($parts) === 2)
{
$new_flashdata_key = $this->flashdata_key.':new:'.$parts[1];
$this->set_userdata($new_flashdata_key, $value);
}
}
}
The problem with this, is that the session is loosing the data when it gets updated. It only happens when I set to use the database to sotre the session data, as I need to.
Any solution to use session data inside the language files ?