ASP.NET session state store provider for MySql (Update) 4

As joel and Ciprian Tarta mentioned, the code for the MySQL session state store provider contained a little bug in the RemoveItem method. I fixed this bug and also tried to re-format the document. 

You can download the document here.



Leave a comment

Your email address will not be published. Required fields are marked *

4 thoughts on “ASP.NET session state store provider for MySql (Update)

  • Harry

    As stated in the comments section of the source code, this is the desired behavior.This session state store provider does not automatically clean up expired session item data. It is recommended that you periodically delete expired session information from the data store with the following code (where ‘conn’ is the MySqlConnection for the session state store provider):string commandString = "DELETE FROM sessions WHERE Expires < ?Expires";MySqlConnection conn = new MySqlConnection(connectionString);MySqlCommand cmd = new MySqlCommand(commandString, conn);cmd.Parameters.Add("?Expires", MySqlDbType.DateTime).Value = DateTime.Now;conn.Open();cmd.ExecuteNonQuery();conn.Close();Alternatively, one can set a Scheduled Task for execute the following:mysql -u<UserName> -p<Password> -h<DB Host Name> DB_Name -e"DELETE FROM sessions WHERE Expires < NOW();"