• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI3 Session Not Expiring On Browser Close

#1
Hi guys,

Using Codeigniter 3.1.2.

Below are my config details for session.

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 7200;
$config['sess_regenerate_destroy'] = FALSE

I am told that upon setting the sess_expiration to 0 that it would be destroyed upon browser close.

However, this does not seem to happen.

Any idea?
Any method I can use to utilise this?

Using javascript seems not practical since it gets triggered when used the back button and when going to a different URL.
Reply

#2
It is possible if you change the sess_time_to_update with 1 day (means session destroy after 24 hour)
Reply

#3
I need the session to be destroyed when the user closes the browser
Reply

#4
You can try this but make sure you clear your browsers cache before testing it again.

ini_set('session.cookie_lifetime', 0);
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#5
Thank you for the reply.

I added your code to the constructor of the of the default controller.

PHP Code:
public function __construct()
        {
                
parent::__construct();
                
ini_set('session.cookie_lifetime'0);
        } 

But it still seems to have no effect.
Any idea why?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.