osCommerce sessions table HUGE?

If your osCommerce sessions table is the largest table in your database and seems to have grown without bounds, don’t worry – the fix is simple.

Edit the file includes/functions/sessions.php and modify the function tep_session_start. At the top of the function, you want to add

@ini_set('session.gc_probability', 1);
@ini_set('session.gc_divisor', 2);

Once this file has been installed, and once a few visitors have come to your osCommerce store, the table will be smaller. But wait! You’re not done yet.

Go into PHPMyAdmin and select your store’s database. Select the sessions table, and at the bottom of the list of tables, press the “With selected:” dropdown and select “Optimize table”. This will take a minute to run, and once it’s complete, you’ll see a big reduction in the size of your sessions table.

How the osCommerce sessions table looked before (1G)
How the table looked before (1G)
How the table looked after (48 Kb)
How the table looked after (48 Kb)

Photo credit: image by James Hammond on Unsplash.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.