The issue is fixed. I had form authentication signout code in Page_Load of error.aspx page. So in some cases its going to error.aspx and coming back it is clearing the session.
FormsAuthentication.SignOut();
Session.Abandon();
So after moving the above code into some events in the page it is working fine.