1
votes

In the past when coding with pure php (without any frameworks), I set a session with $_SESSION and when I close the browser session destroyed and when I set a cookie it will be available until that expire time !

But in Codeigniter framework when I set a session with $this->session->set_userdata($someData) and close the browser and open it again the session is unavailable.

I want to create a login form with Remember Me functionality, when a user checked the Remember Me checkbox login and set some cookie and when not checked, login with simple session (simple session means when the user close his/her browser the session is destroyed and when open browser again he/she is not logged in the system).

But in codeigniter framework when I try to create login form with set_userdata($someData) the session is alive after closing the browser and this is my problem.

Are sessions and cookies the same in codeigniter? How can I create a login system with Remember Me functionality in codeigniter ?

2
Take a leisurely stroll through the codeigniter config file - application/config/config.php starting about Line 327.cartalot

2 Answers

1
votes

You can check and change session expiration time in: /application/config/config.php file. There is line 372, default value is 7200 (sec).

$config['sess_expiration'] = 7200;
0
votes

Codeigniter does not use the native PHP sessions you can read it here:

Session Class

By default the sess_expire_on_close is set to false, so you need to initialize it to true so it will expire upon closing.

With regards to remember me policy here is also a good read i have adopted:

What is the best way to implement “remember me” for a website?

Hope this helps