Part of the EllisLab Network
   
 
Saving sessions data in database and non-persistent cookies
Posted: 16 August 2007 02:43 AM   [ Ignore ]  
Summer Student
Total Posts:  11
Joined  10-28-2006

Finally I have decided to publish a little extension of the Session.php library. MY_Session.php allow non-persistent cookies with easy config:

$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 grin.

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

Profile
 
 
Posted: 25 December 2007 12:45 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  12-25-2007

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.

 Signature 

Oh God… Why didn’t you show me CodeIgniter before?

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64455 Total Logged-in Users: 21
Total Topics: 80961 Total Anonymous Users: 0
Total Replies: 435697 Total Guests: 184
Total Posts: 516658    
Members ( View Memberlist )