We are using CDbHttpSession for sessions, but today when we checked the table it had results which had expiry time of Dec. 2012, that means it is not deleting the expired data…
Is it an expected behavior, It is for sure slowing down the site as the table now has 2M records, out of which 1.9 M are of < expiry date…
So what is that we are doing wrong, any suggestions??
Set up a cron job to clean up old records. You may use a CConsoleCommand to do so, eg:
class SessionCommand extends CConsoleCommand
{
public function actionCleanUp()
{
Yii::app()->db->createCommand("DELETE FROM yiisession WHERE expire > UNIX_TIMESTAMP()")->execute();
}
}