tutmeister Posted August 15, 2011 Report Share Posted August 15, 2011 This table is huge in my database and I'd like to run the following as a weekly Cron Job: <?php $connect = @mysql_connect("localhost","username","password"); if (!$connect) { die('Could not connect: ' . mysql_error()); } @mysql_select_db("database"); // DELETE empties the table $query = "DELETE FROM `phpvms_sessions` WHERE `logintime` < date_sub(NOW(), INTERVAL 2 DAY);"; mysql_query($query); ?> Is there anything other than storing current login details that this table is responsible for that I would be screwing up by doing this? The reason I am doing the above is that I have changed the MySQL table to the Memory Storage Engine and I don't want more than 2 day's worth of sessions loaded into memory. Quote Link to comment Share on other sites More sharing options...
tutmeister Posted August 19, 2011 Author Report Share Posted August 19, 2011 *BUMP* Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted August 19, 2011 Moderators Report Share Posted August 19, 2011 Is this not already a function in the maintenance.php script? Also the session limit is currently set to 30 days i believe, there is a setting in the config file. Quote Link to comment Share on other sites More sharing options...
tutmeister Posted September 3, 2011 Author Report Share Posted September 3, 2011 Sorry Mark, I only just saw this reply. I'm not sure but I will take a look. It might possible kill all open sessions, but the issue at hand, for me at least, is not the amount of sessions. It's that it stores a record for each session which in turn unnecessarily is bloating my database with a year's worth of sessions (well not anymore, as I've run my script to delete them). My host (mediatemple) has a limit on the size a database can be, so I try to get rid of unnecessary bloat. Quote Link to comment Share on other sites More sharing options...
HighFlyerPL185 Posted October 19, 2015 Report Share Posted October 19, 2015 What happens if you remove all the data from that table? It really is big! Quote Link to comment Share on other sites More sharing options...
OzFlyer Posted August 19, 2016 Report Share Posted August 19, 2016 I would also know how to clean out / delete this table. or at least let me know which file and what to change to set it to 30 day log only. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted August 20, 2016 Moderators Report Share Posted August 20, 2016 You can just clear it out manually, all that will happen is users will have to login again. Dont delete the table just empty or truncate. I dont think the native function works to empty the table. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.