What is the elgg version? Which steps did you take to perform the server migration?
Did you read http://learn.elgg.org/en/2.0/admin/duplicate-installation.html ?
Some old discussion postings seem to indicate that you can empty (not delete) this table - but I can not give ANY advice here by own experience! Maybe it's best to backup the database before trying this out. Emptying the table would also result in all users getting logged out.
Possibly it's a php.ini setting resulting in the table getting so big. It might help to set the php variable session.gc_probability to 1 for some php garbage collection. But I can't give some definite advice here either as the garbage cleanup done by php might be working differently on different servers.
This issue (sessions not being cleaned up) still arises some times, as php default setting is not always set so that the garbage collector runs.
The best way to handle this is to set the proper php settings in php.ini file :
session.gc_maxlifetime = 604800
session.gc_probability = 1
session.gc_divisor = 1000
If this option is not available, truncate is harmful and can be done on the full table.
However, to avoid disconnecting logged in users, thruncate only sessions where "ts" is older than session duration should be removed, e.g. for a session duration of 1 day <=> 86400 seconds, we would only delete rows where "ts" is below current ts minus 86400 :
So SQL would be :
DELETE FROM `elgg_users_sessions` WHERE `elgg_users_sessions`.`ts` < 1633245876;
or better :
DELETE FROM `elgg_users_sessions` WHERE `elgg_users_sessions`.`ts` < (UNIX_TIMESTAMP(NOW()) - 86400);
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.