This report is showing all of the rows in the table "session". These are supposed to be deleted when they are untouched for more than one hour but the session object will not always clean up in as timely a manner as we want for this report to be accurate.
So, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, you can make the following modification to the file \admin\controller\report_online.php
replace this
with this
If you want the values shown in the report to be less than 1 hour old, say up to 20 minutes old instead, then those records will expire in 40 minutes from now. Hence, you would change $parsed to the following
So, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, you can make the following modification to the file \admin\controller\report_online.php
replace this
Code: Select all
$results = $database->getRows("select value, ip, time, url from session");
Code: Select all
// show only sessions that have not expired.
$sql = "select `value`, `ip`, `time`, `url` from `session` where `expire` > '?'";
$parsed = $database->parse($sql, time());
$results = $database->getRows($parsed);
//
Code: Select all
$parsed = $database->parse($sql, time() + 40 * 60);
Last edited by bruce on Fri Jan 25, 2008 10:11 pm, edited 1 time in total.
I've the same problem...all the session weren't deleted (I still use 0.6.5), I don't know why. What suggested doesn't solve the problem, only hide it. So, I made these modifications: in file include/session.php, replacedmaryh wrote: CAN anyone help?? - I have 44 customers online!! on my reports page. MOST of these are ME - looking at my store! Can anyone tell me how I can clear these??? Delete doesnt work. Thanks and best wishes
Code: Select all
function clean($maxlifetime) {
global $database;
$database->query("delete from session where expire < '" . time() . "'");
return $database->affected();
}
Code: Select all
function clean() {
global $database;
$database->query("delete from session where expire < '" . time() . "'");
return $database->affected();
}
Code: Select all
$session->clean();
Code: Select all
$session = new session;
Webmaster http://www.opencart.it
Here is a guide how to get Online Reports working in version 0.7.7
The first thing is to find session.php
/library/session/session.php
in the third line edit
to set the expire time in seconds
then
go to /admin/index.php and insert following
by me its working fine

The first thing is to find session.php
/library/session/session.php
in the third line edit
Code: Select all
var $expire = 3600;
then
go to /admin/index.php and insert following
Code: Select all
// People Online
$session =& $locator->get('session');
$session->clean();


hallo!
I've tried bruce and sutulustus solutions - the one of sutulustus gives me an error in the login panel - the one of bruce seems to work but only if I go inside the "people online" panel - the problem is that the number under the "people online" icon doesn't accord with the number of customers online displayed in the panel...
I've tried bruce and sutulustus solutions - the one of sutulustus gives me an error in the login panel - the one of bruce seems to work but only if I go inside the "people online" panel - the problem is that the number under the "people online" icon doesn't accord with the number of customers online displayed in the panel...
Yes, I've imagined... but it seems to be not so linear (at least for me...)
in admin/controller/home.php i've found this part of code
if this is the right part to modify, could you help me to understand how I have to modify it? or, if it's not the right file, could you show me the right one?
thank bruce
in admin/controller/home.php i've found this part of code
Code: Select all
$view->set('online', $url->ssl('report_online'));
$user_info = $database->getRow("select count(*) as total from session");
$view->set('users', $user_info['total']);
$view->set('customer', $url->ssl('customer'));
$customer_info = $database->getRow("select count(*) as total from customer");
$view->set('customers', $customer_info['total']);
thank bruce

you found the right place trippy.
As per my previous preamble, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, change the
to
as before, If you want the values shown in the report to be less than 1 hour old, say up to 20 minutes old instead, then those records will expire in 40 minutes from now. Hence, you would change $parsed to the following
As per my previous preamble, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, change the
Code: Select all
$user_info = $database->getRow("select count(*) as total from session");
Code: Select all
$sql = "select count(*) as total from `session` where `expire` > '?'";
$parsed = $database->parse($sql, time());
$user_info= $database->getRow($parsed);
Code: Select all
$parsed = $database->parse($sql, time() + 40 * 60);
The Customers Online is a useful tool for gathering info when configured as Bruce has described. Very interesting watching how users navigate through various parts of the store and its processes - if you have the time!
On our implementation of OpenCart the No. of Cart Items on this page is always 0 - even though we know they have items in there. Can anyone explain what needs doing to rectify this?
Chris
On our implementation of OpenCart the No. of Cart Items on this page is always 0 - even though we know they have items in there. Can anyone explain what needs doing to rectify this?
Chris
Chris @ SiteE@se Web Design
Hi Chris,
You have found another bug. Change the file admin/controller/report_online.php as shown below. The original offending line is commented out and it's replacement is above it.
Note that the data displayed by this report is not updated in real time. It depends entirely on when the web server decides to persist the session data. That action is captured by code in library/session/session.php which saves it to the database. Only then will it appear in the report.
cheers
Bruce
You have found another bug. Change the file admin/controller/report_online.php as shown below. The original offending line is commented out and it's replacement is above it.
Code: Select all
$rows[] = array(
'name' => $name,
'time' => date('dS F Y h:i:s A', strtotime($result['time'])),
'ip' => $result['ip'],
'url' => $result['url'],
'total' => (isset($value['cart']) ? array_sum($value['cart']) : 0)
// 'total' => (isset($value['products']) ? count($value['products']) : 0)
);
cheers
Bruce
You probably need to include the following in admin -> index.php, as suggested earlier in this thread. Bruce's coding has largely been included in 0.7.8 so you may only want to adjust things in the reports_online.php if you want to show people online less than an hour ago, as Bruce has already described. The code below was not included in 0.7.8 AFAIK.ried wrote: i have 0 customers online (include me 0)...
OC v0.7.8...
Code: Select all
// People Online
$session =& $locator->get('session');
$session->clean();
Chris @ SiteE@se Web Design
Does the People Online report work in 0.7.9RC3 ?
I'm getting noone online even though I am online
I put in the following
I'm getting noone online even though I am online
I put in the following
But got error that Warning: Missing argument 1 for Session::clean(), called in ....admin\index.php on line 138 and defined in .....\library\session\session.php on line 80SiteE@se wrote: You probably need to include the following in admin -> index.php,Code: Select all
// People Online $session =& $locator->get('session'); $session->clean();
I have the same thing with 7.8.
That function,$session->clean();, was someones fix. It is not what is in 7.8 or 7.9.
You would have to use $session->clean(3600) as it needs a parameter.
But that won't cure the problem of no online report.
I'd haven't had time to get back yet, so if you find the answer.let me know too.
That function,$session->clean();, was someones fix. It is not what is in 7.8 or 7.9.
You would have to use $session->clean(3600) as it needs a parameter.
But that won't cure the problem of no online report.
I'd haven't had time to get back yet, so if you find the answer.let me know too.
Brent
I found it
In admin/controller/report_online.php, the line
If you go back up and read Bruce's code, it is
Take out the and it now works
Also follow Bruce's help for Trippy and home.php
I don't understand what + 3600 means but at least I can see me online now
The only thing is it is showing me as admin when I have logged in as someone else in the front end.
I am admin in the backend and some other email address in the front end. Maybe it's identifying the IP address as the same so it's saying I am me.
Maybe Open Cart has esp and just knows I am me
In admin/controller/report_online.php, the line
Code: Select all
$parsed = $database->parse($sql, time()[color=red] + 3600[/color]);
Code: Select all
$parsed = $database->parse($sql, time());
Code: Select all
+ 3600
Also follow Bruce's help for Trippy and home.php
I don't understand what + 3600 means but at least I can see me online now
The only thing is it is showing me as admin when I have logged in as someone else in the front end.
I am admin in the backend and some other email address in the front end. Maybe it's identifying the IP address as the same so it's saying I am me.
Maybe Open Cart has esp and just knows I am me
I came up with this:
Which will show you only sessions that are within the hour from "right now".
But I guess really expire times will never be more than 1 hour from right now anyway. So then yea bruces fix looks like it might be the best way to go on this one
Code: Select all
$sql = "select `value`, `ip`, `time`, `url` from `session` where `expire` >= '?' and `expire` <= '?'";
$parsed = $database->parse($sql, time(), time() + 3600);
$results = $database->getRows($parsed);
But I guess really expire times will never be more than 1 hour from right now anyway. So then yea bruces fix looks like it might be the best way to go on this one
Who is online
Users browsing this forum: No registered users and 0 guests