The default session library in Code Igniter only stores “userdata”. These aren’t really sessions, but rather encrypted cookies. Cookies are stored client-side, which may cause major security compromises. This library extends the default session class with “serverdata” - actual server-side sessions. It also adds options to prevent session hijacking, such as regenerating the session id, encrypting the session cookie, validating ip- and user-agent consistency and/or session lifetimes.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
*
* SESSION FIXING LIBRARY
*
* Code Igniter is cool, but its sessions are rubbish.
* They're actually not even sessions, but encrypted cookies.
* Encrypted or not, session data should NOT be stored client-side.
* It's security-suicide; the encryption can be broken.
* When that happens, hackers write their own session content.
*
* Still, for cookies, they are nicely protected.
* We'll use them to store the session id. (NOT session data)
*
*
* This library extends the default session library.
* Instead of only managing userdata, it allows manipulation of serverdata as well.
*
*
*
* When called, the session class now starts or loads an actual session.
* Extra security to avoid session hijacking:
* - Session id is stored in an encrypted cookie
* - Sessions not started by session->start are denied
* - When the user agent changes, session aborts (optional)
* - When the ip address changes, session aborts (optional)
* - Regenerates session id whenever using it (optional)
*
* @copyright Stratadox 2013
* @link <a href="http://www.stratadox.com">http://www.stratadox.com</a>
* @php 5.4+
*
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */The source code is available through this link:
stratadox.com/CI_Session_Class.zip