Website membership - Pages Visited / Logoff Time

By dm - January 17, 2013

Hi,

I have a login log page set up to record details of when users enter the membership area pages giving me a simple list with username, time entered and ip as per the following posts

http://www.interactivetools.com/forum/forum-posts.php?postNum=2217409#post2217409

http://www.interactivetools.com/forum/forum-posts.php?postNum=2213350#post2213350

Does anyone know a way to record when the user logs off (or logged on time) and what membership pages were visited?

Many thanks for you help!

Hi,

There is a way you can do this, but it does require you to modify the code of the website membership plugin slightly, which isn't something we recommend. So if you upgrade the plugin at a later date, you will have to add this feature back into it. Also this will only record users when they press the log off button, if they let there session expire or close the browser then there isn't really a way you can record the action.

First you'll need to create a section that can store the information. I've attached a screenshot of how I set up my section, I named the section logged off.

Next you'll need to open your websiteMembership.php file from your plugins folder in CMS Builder.

You'll need to find the _websiteLogin_logoff function which will probably be around line 150. Then add the following code that is highlighted in green at the beginning of the function:

// remove login cookies

function _websiteLogin_logoff() {

global $CURRENT_USER;

mysql_insert('logged_off', array('userNum' => $CURRENT_USER['num'], 'username' => $CURRENT_USER['username'], 'time' => date('Y-m-d H:i:s'), 'ip' => $_SERVER['REMOTE_ADDR']));

// get logoff url
if ($GLOBALS['WEBSITE_LOGIN_POST_LOGOFF_URL']) {

......

The global $current user will get the current users data, and the mysql_insert function will add a new record to the logged_off section.

Let me know if you have any problems implementing this system.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

section-layout_002.png 6K

By dm - January 25, 2013 - edited: January 31, 2013

many thanks for all your help greg its really appreciated!

in the decade or so that i have been using interactivetools software i have yet to come across another company with such consistently great support! keep up the good work!