Welcome Guest, Not a member yet? Register   Sign In
Questions about sessions in CI 3.0
#1

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 ?
Reply
#2

(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.
Reply
#3

Thanks, now I understand it.
Reply
#4

(This post was last modified: 01-28-2015, 01:18 PM by twpmarketing. Edit Reason: spelling... )

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?
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB