You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My IT department are running a monitoring system that checks for errors etc, and that script runs every second and generates a new session class initialization, which in turn creates a new row in the database. That's one new row every second!
My IT department can't do much about this on their end. Do you have an idea on how I can attack this problem? I think this happens since the class constructor executes all functions and I need to initiate the class on my index.php to check if a user is logged in or not, and that's the page the monitoring system looks at. Can empty rows (with empty data column) be deleted automatically or can a new row only be created when I run my login script?
On my localhost I don't have this issue. Otherwise the code works great! :)
The text was updated successfully, but these errors were encountered:
I solved this by adding this code at the end of the constructor:
$this->_gc(10, 180)
and this in the _gc($max, $maxLoggedIn) method:
$old = time() - $max;
$oldLoggedIn = time() - $maxLoggedIn;
$this->db->query('DELETE FROM sessions WHERE (access < :old AND data = "") OR (access < :oldLoggedIn)');
$this->db->bind(':old', $old);
$this->db->bind(':oldLoggedIn', $oldLoggedIn);
$max = if a visitor does not set a session, their row will be deleted, until they set a session
$MaxLoggedIn = if a logged in user (in this case) has data in the data cell in the db and has been inactive (not updated the page) for this amount of seconds, their row will be deleted. In this case logged out.
This is might only be needed in my specific case, because of the monitoring script, but this provides some control of old data and a way to set a max session time for your users.
My IT department are running a monitoring system that checks for errors etc, and that script runs every second and generates a new session class initialization, which in turn creates a new row in the database. That's one new row every second!
My IT department can't do much about this on their end. Do you have an idea on how I can attack this problem? I think this happens since the class constructor executes all functions and I need to initiate the class on my index.php to check if a user is logged in or not, and that's the page the monitoring system looks at. Can empty rows (with empty data column) be deleted automatically or can a new row only be created when I run my login script?
On my localhost I don't have this issue. Otherwise the code works great! :)
The text was updated successfully, but these errors were encountered: