I want to keep track of User Sessions within my MVC webapp. I know I am doing something wrong because the flow of the programming seems kind of chaotic. Any suggestions? At this point I am trying to verify Session every time I hit a different controller.
private void VerifiedUserSession()
{
int? userID = (int?)Session["UserID"];
if (userID.HasValue)
{
IUsersRepository userRepository = new SQLUserRepository();
_user = userRepository.GetUser(userID.Value);
}
//TODO: Need to create a response for where the session is empty or null;
}