• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to store "custom session data" in sessions table?

#1
[eluser]inktri[/eluser]
So I'm using the session class and want to store in the sessions table more than just the IP, session id, etc. How can I store the custom session data such as username, and logged_in in the sessions table? I tried altering the schema so each sessions record has a username field and a logged_in field; however the values of those fields never change accordingly.

Code:
$newdata = array(
                   'username'  => 'johndoe',
                   'email'     => 'johndoe@some-site.com',
                   'logged_in' => TRUE
               );

$this->session->set_userdata($newdata);

#2
[eluser]Dready[/eluser]
You'll find in the wiki ( http://codeigniter.com/wiki/DB_Session/ ) a drop-in replacement for CodeIgniter sessions, that will fit your needs.

#3
[eluser]llbbl[/eluser]
its usually not a big deal, storing them in the cookie as long as you don't store a bunch of stuff. you might try encrypting the cookie if your worried about cross site cookie hax.

if you store it in the database, you will still need to set the cookie with the session key, so your going to be using cookies one way or another. setting the cookies helps prevent things like people logging on with different computers in a network, so like you could use your coworkers account if you could successfully duplicate his user agent.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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