Massive Session Logs and Database
-
shopify
- Member
- Posts: 54
- Joined: Tue Mar 30, 2021 3:36 pm
- Phoenix Version:
- Has thanked: 23 times
- Been thanked: 3 times
Massive Session Logs and Database
When backup up my database, I've observed file is getting massive each time because of session logs in it. Is there a use for this and why isn't there a way to clear it in the admin panel? Surely there must be a way to reset this?
Also, is there a way to reset the product views?
Also, is there a way to reset the product views?
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Massive Session Logs and Database
In php.ini, change your garbage collection settings. E.g.
I don't know of a way to reset product views other than in phpMyAdmin. It's products_viewed in the products_description table.
Code: Select all
session.gc_maxlifetime = 86400
session.gc_probability = 1
session.gc_divisor = 1000-
shopify
- Member
- Posts: 54
- Joined: Tue Mar 30, 2021 3:36 pm
- Phoenix Version:
- Has thanked: 23 times
- Been thanked: 3 times
Re: Massive Session Logs and Database
I don't know or have access to my hosting php.ini file. It's phoenix this is logging to the cart database, not my hosting. So I don't know why you have said I should modify the php.ini file.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Massive Session Logs and Database
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: Massive Session Logs and Database
If you have no access to these settings, you can use this hook to delete old sessions each time the admin index page is loaded:
copy the following code in a new file and save it as "destroySession.php in:
includes/hooks/admin/siteWide/destroySession.php
copy the following code in a new file and save it as "destroySession.php in:
includes/hooks/admin/siteWide/destroySession.php
Code: Select all
<?php
class hook_admin_siteWide_destroySession {
var $maxlifetime = 259200; // 72 hours
function listen_injectSiteStart() {
if ($GLOBALS['PHP_SELF'] == 'index.php') {
tep_db_query("DELETE FROM sessions WHERE expiry < '" . (time() - $this->maxlifetime) . "'");
}
}
}
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
-
shopify
- Member
- Posts: 54
- Joined: Tue Mar 30, 2021 3:36 pm
- Phoenix Version:
- Has thanked: 23 times
- Been thanked: 3 times
Re: Massive Session Logs and Database
Thanks for all suggestions. So I have added last suggested file in hooks. How is this new file destroySessions.php activated? I'd have thought I have to add it as an include somewhere?
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: Massive Session Logs and Database
Hooks are auto loaded, they just need to be in their correct directory.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
-
shopify
- Member
- Posts: 54
- Joined: Tue Mar 30, 2021 3:36 pm
- Phoenix Version:
- Has thanked: 23 times
- Been thanked: 3 times
Re: Massive Session Logs and Database
I did not know that, I've learnt something new today. Thanks for the education.
-
ThatSweetShop
Re: Massive Session Logs and Database
I have same issue with products viewed counts. Why isn't there a way in the app to reset these? This is obviously a flaw that needs fixing. Is someone able to provide a solution for this like your hook for other issue poster had?ecartz wrote: ↑Sun Apr 11, 2021 1:07 am In php.ini, change your garbage collection settings. E.g.
I don't know of a way to reset product views other than in phpMyAdmin. It's products_viewed in the products_description table.Code: Select all
session.gc_maxlifetime = 86400 session.gc_probability = 1 session.gc_divisor = 1000
-
ThatSweetShop
Re: Products viewed
I got someone to do this for me to reset products viewed 
Code: Select all
<?php
require('includes/application_top.php');
require('includes/template_top.php');
if(isset($_POST['reset'])) {
if ($GLOBALS['PHP_SELF'] == 'stats_products_viewed.php') {
tep_db_query("UPDATE `products_description` SET products_viewed=0");
}
}
?>
<h1 style="font-size: 28px;" class="display-4 mb-2"><?php echo HEADING_TITLE; ?></h1>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th><?php echo TABLE_HEADING_NUMBER; ?></th>
<th><?php echo TABLE_HEADING_PRODUCTS; ?></th>
<th class="text-right"><?php echo TABLE_HEADING_VIEWED; ?></th>
</tr>
</thead>
<tbody>
<?php
if (isset($_GET['page']) && ($_GET['page'] > 1)) $rows = (int)$_GET['page'] * MAX_DISPLAY_SEARCH_RESULTS - MAX_DISPLAY_SEARCH_RESULTS;
$rows = 0;
$products_query_raw = "select p.products_id, pd.products_name, pd.products_viewed, l.name from products p, products_description pd, languages l where p.products_id = pd.products_id and l.languages_id = pd.language_id order by pd.products_viewed DESC";
$products_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows);
$products_query = tep_db_query($products_query_raw);
while ($products = tep_db_fetch_array($products_query)) {
$rows++;
?>
<tr onclick="document.location.href='<?php echo tep_href_link('categories.php', 'action=new_product_preview&read=only&pID=' . (int)$products['products_id'] . '&origin=stats_products_viewed.php?page=' . (int)$_GET['page']); ?>'">
<td><?php echo str_pad($rows, 2, '0', STR_PAD_LEFT); ?>.</td>
<td><?php echo '<a href="' . tep_href_link('categories.php', 'action=new_product_preview&read=only&pID=' . $products['products_id'] . '&origin=stats_products_viewed.php?page=' . (int)$_GET['page']) . '">' . $products['products_name'] . '</a> (' . $products['name'] . ')'; ?></td>
<td class="text-right"><?php echo $products['products_viewed']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-sm-6"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div class="col-sm-6 text-sm-right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></div>
</div>
<br />
<div class="row">
<div class="col-sm-6"> </div>
<div class="col-sm-6 text-sm-right">
<form action="<?php echo tep_href_link($PHP_SELF) ?>" method="post">
<input type="submit" name="reset" value="Reset Viewed" />
</form>
</div>
</div>
<?php
require('includes/template_bottom.php');
require('includes/application_bottom.php');
?>