Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Identifying 'active' sessions

Questions related to using nuBuilder Forte.
Locked
nac
Posts: 115
Joined: Tue Dec 12, 2017 11:28 pm
Location: Aberdeen, UK
Has thanked: 9 times
Been thanked: 12 times

Identifying 'active' sessions

Unread post 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
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Identifying 'active' sessions

Unread post 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
nac
Posts: 115
Joined: Tue Dec 12, 2017 11:28 pm
Location: Aberdeen, UK
Has thanked: 9 times
Been thanked: 12 times

Re: Identifying 'active' sessions

Unread post 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
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Identifying 'active' sessions

Unread post by admin »

.
Locked