• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving sessions data in database and non-persistent cookies

#1
[eluser]Unknown[/eluser]
Finally I have decided to publish a little extension of the Session.php library. MY_Session.php allow non-persistent cookies with easy config:
Code:
$config['sess_cookie_isnonpersistent'] = TRUE;

And also, I have not the cookie data limit of 4KB (because session data is stored in database).

The code is very simple and I have used serialize function for storing data in a TEXT field. Also, you can save data in cookies using the new method set_userdata_cookies. The old method userdata first look at the session db info, and later in the cookie :-).

It is perfect if you don't want to expose sensitive data in cookies or save more and more information in sessions.

More details in my blog.
Download: MY_Session.zip

#2
[eluser]Edemilson Lima[/eluser]
I liked very much your implementation to save session vars in the database. In fact, it was my first idea too. But isn't the PHP native session engine made in compiled C code faster than any implementation made in PHP code?

My main concern is: how much these implementations using cookies or databases are better to save server resources? How does PHP native session behave when we have thousands of simultaneous users?

I think you could made it more flexible using $this->CI->config->item('sess_table_name') to get the name of the session database from the config file.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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