CodeIgniter - how to query DB session?
My CI sessions are stored in my database.
I have a native PHP script outside of CodeIgniter that needs some information that's in userdata. Is there a way for my to query the CI session table and figure out what the current user's session is? I think CI checks the user IP and the "first 120 characters of the browser data string." Those 2 pieced of data are available to that outside script, right? Can I query for those 2 fields and get an accurate result? Or is CI somehow aware of what the session_id is?
Alternatively, I thought I could could set a native session variable from CI containing the information I needed and try to access it in the outside PHP script. It didn't work.
I'm open to suggestions.
I used this code to integrate comet chat(an external app) with my CI user system: you might need to modify it but you can get the gyst:
$decoded_ci_session = @unserialize(@stripslashes($_COOKIE['ci_session'])); $sql = "SELECT user_data FROM ".TABLE_PREFIX."sessions WHERE session_id = '".$decoded_ci_session['session_id']."'"; $query = mysql_query($sql); $row = mysql_fetch_array($query); $decoded_ci_session = @unserialize(@stripslashes($row));
at the end $decoded_ci_session should contain all the userdata normally in $this->session->userdata()