Reputation: 2013
I've just started using CodeIgniter 2. I resisted a framework for so long but have finally realised that my mish mash collection of classes, functions, config files is a nightmare to keep updated across multiple projects.
I was looking at CI's session class and noticed the following:
A useful aspect of the session array is that you can add your own data to it and it will be stored in the user's cookie. Why would you want to do this?
Arrrgghh! That sounds so wrong to me for so many reasons. Here's my question...
Is it possible to use PHP's native session functions and access $_SESSION
when using CodeIgniter?
Or is there something in CI that will prevent me from doing so? Any security features that deny direct access to super globals or something?
I found this but it looks like it's designed for CI 1.5 and I'm not sure how updated it would be. I think I would prefer to use my own wrappers for PHP's native sessions - if I can actually use PHP's native sessions.
I should also add that I'd prefer not to store sessions in a DB either, in case of connectivity/latency issues.
Upvotes: 1
Views: 3614
Reputation: 33710
Inside config.php
there is a option which is default to use cookies:
$config['sess_driver'] = 'cookie';
Description
'sess_driver'= the driver to load: cookie (Classic), native (PHP sessions),
So it looks like you could change this to use native PHP sessions.
Upvotes: 2
Reputation: 905
http://codeigniter.com/user_guide/libraries/sessions.html
Codeigniter session class creates it's own session data. So it has nothing to do with PHP's native session and yes you can use them.
One benefit is that you can easily save youre session data in the database.
Upvotes: 4