CodeIgniter Forums
sess_expire_on_close - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: sess_expire_on_close (/showthread.php?tid=63744)

Pages: 1 2


sess_expire_on_close - rolly - 12-06-2015

Hello everyone...
I know, what in 3 version this param sess_expire_on_close was delete.
How remove session after close browser?
Okay. I know if set config sess_expiration = 0 session close ...

but if I make


PHP Code:
$this->config->set_item('sess_expiration'0);
$this->load->library('session'); 

not work, load only 

PHP Code:
$config['sess_expiration'] = 600; --> config.php 

[Image: f04ad9e6-9bb8-11e5-9c9a-9a6fe1dc486f.png]
config.php

[Image: 12f7d7c8-9bb9-11e5-927c-601b1f3264d2.png]

but when I show var_dump($this->config->item('sess_expiration')); I see = 0, but if I close browser and open again session live..., if I change sess_expiration = 0 in config.php file - session die after close browser.


RE: sess_expire_on_close - InsiteFX - 12-06-2015

set_item is not permanent, it will reset.


RE: sess_expire_on_close - Narf - 12-07-2015

So set the value in the config file ...


RE: sess_expire_on_close - rolly - 12-07-2015

ok, but some time I need
[Image: -929206895.png]
how make?


RE: sess_expire_on_close - rolly - 12-07-2015

If I make sess_expiration = 0, all session destroy after close browser, but sometimes I need save session for somebody


RE: sess_expire_on_close - PaulD - 12-07-2015

Write what you need to a different, separate cookie. Store whatever info you need on it.

When they come back to your index page (say) or login page, check for the existence or not of the non expiring cookie.

Hope that helps,

Paul.


RE: sess_expire_on_close - jlamim - 02-16-2016

sess_expiration = 0 not working.

My config:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

I need destroy session when user close window.


RE: sess_expire_on_close - Narf - 02-16-2016

(02-16-2016, 01:14 PM)jlamim Wrote: sess_expiration = 0 not working.

My config:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

I need destroy session when user close window.

That's not how it works.

The event of a browser being closed is undetectable - you don't know if/when that happens and therefore it cannot trigger anything on the server side (meaning it can't effectively destroy the session). Instead, by setting a cookie's expiration time to 0, you tell the browser to only save the cookie in memory and thus not preserve it for the next time it runs. That way the user loses their session ID and cannot link to the same session.
However, the session data itself still exists on the server for some time, until the garbage collector runs and deletes all session files that have been inactive for more than ini_get('session.gc_maxlifetime') seconds.

Also, don't leave sess_save_path empty - you are required to configure that.


Codeigniter session expire on close not working - Nabanita - 04-03-2016

Hello everyone...
I want to override or set config item dynamically. If user logged in without checking remember me checkbox then I want to set sess_expire_on_close value is false and user not checked then sess_expire_on_close value is true. I used the following php code: 

PHP Code:
if($this->input->post('remember')) 
$this->config->set_item('sess_expire_on_close''0');
else
$this->config->set_item('sess_expire_on_close''1'); 
but this process is not working. When I closed then browser without checking remember me dialog then session expire value is set to be 0 but still session is live. If a set config the following value 

PHP Code:
$config['sess_expire_on_close'] = TRUE; --> config.php 
then session will be destroy when closed browser but not store session value when I checked remember me checkbox. Idea


RE: sess_expire_on_close - Nabanita - 04-04-2016

(12-06-2015, 02:38 AM)Hello rolly... Wrote: I want to override or set config item dynamically. If user logged in without checking remember me checkbox then I want to set sess_expire_on_close value is false and user not checked then sess_expire_on_close value is true. I used the following php code: 

PHP Code:
if($this->input->post('remember')) 
$this->config->set_item('sess_expire_on_close''0');
else
$this->config->set_item('sess_expire_on_close''1'); 
but this process is not working. When I closed then browser without checking remember me dialog then session expire value is set to be 0 but still session is live. If a set config the following value 

PHP Code:
$config['sess_expire_on_close'] = TRUE; --> config.php 
then session will be destroy when closed browser but not store session value when I checked remember me checkbox.  Idea






rollyHello everyone...
I know, what in 3 version this param sess_expire_on_close was delete.
How remove session after close browser?
Okay. I know if set config sess_expiration = 0 session close ...

but if I make


PHP Code:
$this->config->set_item('sess_expiration'0);
$this->load->library('session'); 

not work, load only 

PHP Code:
$config['sess_expiration'] = 600; --> config.php 

[Image: f04ad9e6-9bb8-11e5-9c9a-9a6fe1dc486f.png]
config.php

[Image: 12f7d7c8-9bb9-11e5-927c-601b1f3264d2.png]

but when I show var_dump($this->config->item('sess_expiration')); I see = 0, but if I close browser and open again session live..., if I change sess_expiration = 0 in config.php file - session die after close browser.