CodeIgniter Forums
Questions about sessions in CI 3.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Questions about sessions in CI 3.0 (/showthread.php?tid=898)



Questions about sessions in CI 3.0 - GeorgeD - 01-27-2015

1. I see 3 method for accessing/creating sessions:

PHP Code:
$name $_SESSION['name'];

// or:

$name $this->session->name

// or:

$name $this->session->userdata('name'); 
What do you recommand for using and why ?

Files Driver

2. Under what circumstances should I change 'sess_save_path' from NULL ?

3. I have changed 'sess_save_path' from NULL to "sessions", but nothing happend.
Where should a I create the "sessions" folder ?

Database Driver

4. Can I use $_SESSION and Database Driver ?
When we use $_SESSION, the writting/reading are still going through Session library ?


RE: Questions about sessions in CI 3.0 - Narf - 01-27-2015

(01-27-2015, 04:08 AM)GeorgeD Wrote: 1. I see 3 method for accessing/creating sessions:


PHP Code:
$name $_SESSION['name'];

// or:

$name $this->session->name

// or:

$name $this->session->userdata('name'); 
What do you recommand for using and why ?

Personally, I recommend using the $_SESSION superglobal. One of my goals while working on the library was to make it as close as possible to PHP's own ways.

(01-27-2015, 04:08 AM)GeorgeD Wrote: Files Driver

2. Under what circumstances should I change 'sess_save_path' from NULL ?

Under ALL circumstances. It's NULL by default for one simple reason - there's no universal value, you must configure it for yourself.

(01-27-2015, 04:08 AM)GeorgeD Wrote: 3. I have changed 'sess_save_path' from NULL to "sessions", but nothing happend.
Where should a I create the "sessions" folder ?

It's an absolute path. Please read the documentation, it's explained in detail.

(01-27-2015, 04:08 AM)GeorgeD Wrote: Database Driver

4. Can I use $_SESSION and Database Driver ?
When we use $_SESSION, the writting/reading are still going through Session library ?

Yes.


RE: Questions about sessions in CI 3.0 - GeorgeD - 01-28-2015

Thanks, now I understand it.


RE: Questions about sessions in CI 3.0 - twpmarketing - 01-28-2015

I'm using the 'files' session driver and these are the settings that work for me:

$config['sess_save_path'] = '/var/www/html/tmp/sessions';

Permissions on the tmp and sessions directories are set to '777' and ownership is 'root'

The questions are:
How safe are these?
Should I move the tmp directory?
Should I move the sessions directory?