When a user logs into the website, I am creating 5 session variables with some user related values (like \[code\]userid\[/code\],\[code\]roleid\[/code\] etc..). Based on one of the values stored in a session variable, I have to update a record in the database. To do this I am writing the following code in the \[code\]Session_End()\[/code\] event of Global.asax\[code\]if (Session["UserHistoryID"] != null) SessionUtility.UpdateDatabase(Convert.ToInt32(Session["UserHistoryID"]));\[/code\]The problem here with this is when the Session times out and \[code\]Session_End\[/code\] fires the \[code\]Session\[/code\] variable \[code\]Session["UserHistoryID"]\[/code\] is \[code\]NULL\[/code\] some-time and the above condition fails and the record in the database is not updated. When this is tested in my local system it works fine but when I test this in production server some of the records are not getting updatedWhy is this happening? Some one please explain how the \[code\]Session_End\[/code\] works exactly.I have searched everywhere but can't find a solution to this.