Possibility of deleting user manager sessions older than 3 months

Hi,

I am having an issue with my User Manager sessions filling up my database and slowing down the system.

Doing anything in the user manager interface sets 100% CPU. I have been able to resolve by deleting old sessions and logs.

I am looking for a solution that would automate this process.

I would ideally like to set something up, presume it would be a script that would run on the 30th of every month, that will export sessions that are older than 90days to a file and upload to ftp server, then delete those sessions, leaving only the latest entries.

Is there anyone that can assist with a script capable of doing this.

Thanks in advance

better idea, when user get expired, export his sessions to file before remove his sessions
file name = USER_sessions _of_month