Part of the EllisLab Network
   
 
Why use CI Sessions
Posted: 21 November 2008 11:17 PM   [ Ignore ]  
Summer Student
Total Posts:  10
Joined  11-02-2008

I had posted a sessions question a while back and thank you for your answers, but I do have a few more.

What are the benefits of using CI sessions?  It appears to me that one benefit is more control of the life of each session.  Also, I do like not having to session_start on every page.

But the CI session info is stored in cookies / client side. 

Isn’t that more prone to errors and security issues? 

Plus, if cookies are disabled at the user’s browser, then what? I don’t believe browsers can disable PHP sessions, true?

I am sure there are benefits to CI’s version and perhaps I’m not experienced enough to see them.  Isn’t that why you’re here? LOL

John

Profile
 
 
Posted: 22 November 2008 11:10 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  11-28-2007

CI sessions store a limited amount of data in the cookie, which is only used in conjunction with information stored in the session database.  If you want to store sensitive data and have it associated with a logged-in user, store the sensitive information in the database.  That’s plenty secure, seeing as how a hacker would have to guess a large string that changes often.

PHP sessions cannot be disabled via the browser since they are a server-side resource, however PHP sessions have been known to have issues with older browsers (IE6 anyone?).

I won’t say more than that because honestly I don’t have enough experience with user authentication to try and say what’s good and what’s bad.  I do know, though, that the Ellis guys are pretty smart, and I’m sure they’d create something secure for you to use.

Profile
 
 
Posted: 23 November 2008 12:45 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  250
Joined  11-08-2006

Search the forums/wiki and you’ll find plenty of code to make CI’s sessions more useful. As for the question of what happens when the user has cookies turned off, PHP native sessions store the session ID client-side in a cookie as well (falling back passing it in the URL) so basically you’ve got the same problem and security issues with either method.

Have you read the User Guide section on the session library? You’ll see that you can configure the cookie data to be encrypted as well as a couple other options to increase the security.

- K

Profile
 
 
Posted: 23 November 2008 07:13 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  12
Joined  10-14-2008

Personally I would struggle to live without $this->session->flashdata smile

Profile
 
 
Posted: 24 November 2008 12:36 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
RankRankRankRank
Total Posts:  1264
Joined  04-19-2008

I stopped using the CI sessions except for the flashdata when I got a bug with the sess_destroy in 1.7.0. I built my own auth library using native sessions.

 Signature 

PinoyTech - Web Development Blog

Profile