Welcome Guest, Not a member yet? Register   Sign In
Sessions not working as expected...

Well, hello to everybody!

One more time I will need the super heroes of this forum.

All I want to do is to write a session with a language field and it doesn;t work as expected. I do exactly the example as shown at the manual. But it seems that it stores the session only from the page the session data is created and then to the next page. In the third click all session data are lost!

I am using Freak Auth LIght and DB_session class so I tried to write my session data to the database but I don't really find a way to do that. Also in my data base my session table is filled with records, Its time i click to a new page a new record is written.

Maybe some one can point me in the right direction or give me some tips?

Thanks in advance for your help

[eluser]Colin Williams[/eluser]
You probably have a combination of match_user_agent and match_ip (something along those lines in config) that's causing new sessions to be created. I usually have to disable the user_agent one to get things to work correctly.

I tried all combination but doesn't seem to solve the problem!

At the moment I have 3 problems using sessions

1. It doesn't store the data to the table ci_sessions.
2. Passes the session data only in one page
3. Writes session record in every page I visit in my web site!

[eluser]Colin Williams[/eluser]
Post some code from where you're setting the data.

here I set the session.

class Frontpage extends Controller {

function Frontpage(){

function index(){
$newdata = array( 'lang' => 'en' );


$lang = $this->session->userdata('lang');
if ($lang == "en" ){$this->lang->load('en','en');}
/* get the main content of the website */
$profile_query = $this->db->query('SELECT title, text FROM scontent WHERE scontent_id="1"');

$title = "title_".$lang;
$content = "text_".$lang;
$row = $profile_query->row();
/* publish main content */
$data['content'] = '<h1>'.$this->lang->line('wellcome').'</h1>'.$row->$content;

/* publish navigation */
$data['navigation'] = "navigation_".$lang;
$data['footer'] = "footer_".$lang;
$data['meta'] = "meta_".$lang;

$this->load->view('site/template_view', $data);

[eluser]Colin Williams[/eluser]
Hrm.. a db column for each lang... interesting.

Anyway, I don't see anything wrong right away. My gut still says it's a problem in config. Maybe cookie settings or sess timeout?

THe idea is to have the same functionality in all the website without the need to spycify the language

What I do is to create a table lets call it articles and then I have my fields Like title_en, title_fr, text_en, text_fr and so on

It is working really nice for my. It is a way I used in my older hand made from the scratch CMS. But there the only thing I had to do was to set a session with the current language. I can;t really understand why I can't do that with CI and I can't really understand where the problem is!

Any way I keep searching...

Theme © iAndrew 2016 - Forum software by © MyBB