Smart Session with CodeIgniter

1

I have an application developed with CodeIgniter, PHP and MySQL. The user session has always been treated according to the CodeIgniter standard, but now I need the session to be more restrictive, working in a similar way to an internet banking session, expiring in seven minutes (420 seconds) of inactivity, and at each client request with the server these seven minutes are renewed.

I do not know if natively just setting parameters CodeIgniter supports this way of storing the session, but I have not been able to represent this way of working.

I do not know if for this level of restriction I need to reimplement some methods of the CI_Session class, or if I just need to correctly define the CI parameters?

If not, is there already a CodeIgniter class or plugin that already has an activity like this implemented?

Example of how I'm setting the parameters:

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 420; 
$config['sess_encrypt_cookie']          = FALSE;
$config['sess_use_database']            = TRUE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']         = TRUE;
$config['sess_time_to_update']          = 420;
$config['sess_storage']                 = 'database';
$config['sess_database']                = 'default';
$config['sess_timeout']                 = 7200;
$config['sess_destroy_on_timeout']      = FALSE;
$config['sess_update_interval']         = 180;
$config['sess_gc_probability']          = 10;
$config['sess_http_only']               = FALSE;
$config['sess_secure']                  = FALSE;
$config['sess_forwarded_ip']            = FALSE; 
    
asked by anonymous 24.10.2014 / 15:12

2 answers

2

I was able to solve the problem by simply rearranging the CodeIgniter session setup, setting the parameters for session operation in the config.php of my application.

Basically, I checked the CodeIgniter documentation again and removed some of the parameters that were deprecated as of version 2.0.

I used the guidelines of each CI session parameter defined in the figure below:

Inmyapplication,thesessionconfigurationparametersareasfollows:

$config['sess_cookie_name']='fwsibe';$config['sess_expiration']=7200;$config['sess_expire_on_close']=TRUE;$config['sess_encrypt_cookie']=FALSE;$config['sess_use_database']=TRUE;$config['sess_table_name']='ci_sessions';$config['sess_match_ip']=FALSE;$config['sess_match_useragent']=TRUE;$config['sess_time_to_update']=0;

Icametothissolutionthankstothefollowingpostintheinternationalstackoverflow: CodeIgniter Session equal to Internet Banking

    
01.12.2014 / 16:38
2

I think CodeIgniter does not have this, but that's very simple. Any request made in the application where any page that contains session_start() at the beginning, the session will renew itself and begin the count again, that is, it will do the function you want.

If the user gets stuck on the page filling and scrolling and etc, it can be logged, exact? Then also or at least another way to avoid this, is that you have an AJAX function, which calls any page containing session_start() to renew the session if it still has the page open. But this situation can vary a lot, as in a Lan House it finishes the person's time, and in some the browsers remain open depending on Lan's system.

So it's good to think of some logic to manage your application.

    
01.12.2014 / 13:58