• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI session not working properly

I have this configuration:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;

I am getting session value first time. But in next i am not getting session value....
anbody help me

im not using it actually, im using the "Native_session" class for session handling, you can get it here:


it's fast IMO.

[eluser]Derek Allard[/eluser]
you'll need to tell us a bit more about what isn't working in order for us to help.

when i am write the data in a session it is working fine........
but in case of reading session data first time i am getting the session data...
after first time there is no value in the session...
that is in second time posting the value may be replaced by null....
what would be the reason???????????

[eluser]Derek Allard[/eluser]
If you use just the code in the docs, does it work?

If you want, you can post some code.

This is my Login function:
function login(){
            $rules['username'] = 'trim|required|callback_checklogin';
            $rules['password'] = 'trim|required';

            $fields['username']   = 'User Name';
            $fields['password']  = 'Password';



And my callback function is:::::

function checklogin(){
        $uname = $this->input->post('username');
        $pass = $this->input->post('password');
        $password = md5($pass);
        $query = $this->db->get('user');
            $user = $query->result();
            return true;
            $this->validation->set_message('checklogin','User Name and Password do not match');
            return false;

[eluser]Derek Allard[/eluser]
Could I trouble you to reduce this down to session only code?

From where i am writing in the session:
$user = $query->result();//*************************
return true;
$this->validation->set_message(’checklogin’,’User Name and Password do not match’);
return false;

where i am trying to read session data:
$userdata1 = $this->session->userdata('user');
$userdata = $userdata1[0];



[eluser]Derek Allard[/eluser]
Its not that I can't read your code, its that I want to reduce the problem down to only the session so that we can squarely say "the session isn't working". For example, in the code you gave me above, if $user was set to "NULL", then it would be passing a null value, and this would explain the symptoms you see.

In your case above, you are setting a session with the value of $user, but I don't see your user variable defined. I do see a $uname, but don't know where $user is coming from. This is probably the error.

The reason I was trying to get you to reduce down is that you could see that session is working, and focus on why the value isn't getting passed as expected.

Good luck, and welcome to CodeIgniter!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.