Page 1 of 1

Identifying 'active' sessions

Posted: Tue Aug 28, 2018 2:37 pm
by nac
Hello,

My question relates to the records in the zzzzsys_session table. I have noticed that session records are removed if the logout link is used. However, if the user closes the tab/browser or the session times out, the record is not removed. Is there any way of knowing which of the sessions in this table are active? (By 'active', I mean the elapsed time since the last activity is less than the timeout setting. )

I was able to implement a rather simplistic way of storing the date and time of the most recent activity of a session but it required some changes to the table structure and one of the PHP files - something I would rather not do as it would require these edits every time the nuBuilder files are updated. Here is what I did.

Step 1: Modify the session table thus: ALTER TABLE `zzzzsys_session` ADD `sss_last_activity` DATETIME

Step 2: Add one new line of code to nusession.php (around line 218)

Code: Select all

     
 if((($r->set_time_out_minutes * 60) + $_SESSION['SESSION_TIMESTAMP']) >= time()){
    $_SESSION['SESSION_TIMESTAMP'] = time();
     // one new line below - update the last activity time
    nuRunQuery("UPDATE zzzzsys_session SET sss_last_activity = NOW() WHERE zzzzsys_session_id = ?", array($_SESSION['SESSION_ID']));
  }else{
    $_SESSION['SESSION_ID'] = null;

This works OK but I would prefer to use a method that does not require modifications to the nuBuilder files. Is there a better way of doing this?

Thanks.

Neil

Re: Identifying 'active' sessions

Posted: Tue Aug 28, 2018 11:21 pm
by admin
Neil,

zzzzsys_session tables have a field called sss_time. (if it doesn't you need to run the Update button)

If any session remains unused for 5 hours, it will be removed.

Steven

Re: Identifying 'active' sessions

Posted: Tue Aug 28, 2018 11:45 pm
by nac
Thanks Steven - that did the trick. My zzzzsys_session table did not have the sss_time field as I had not updated for a few weeks (Note to self: pull the latest version and run the update before asking a question here!!)

Neil

Re: Identifying 'active' sessions

Posted: Wed Aug 29, 2018 12:55 am
by admin
.