I also use Session in my application to maintain user access data. I consider it faster than searching the direct database.
Question 1
Regarding the loss of Session, I believe that you should set its time-out to a higher value. Change your Web.config as an example below:
<system.web>
<sessionState timeout="60"></sessionState>
...
Another thing I do is in Global.asax.Cs, I see if Session is dead and has Form authentication, I create Session again. Example below:
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState)
{
HttpCookie authenticationCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authenticationCookie != null)
{
FormsAuthenticationTicket authenticationTicket = FormsAuthentication.Decrypt(authenticationCookie.Value);
if (!authenticationTicket.Expired)
{
if (Session["usuarioLogado"] == null)
{
CriaNovamenteSession(authenticationTicket.Name);
}
}
}
else
Session["usuarioLogado"] = null;
}
}
Question 2
I haven’t tried it with so many users yet, but I think it’s better to have 1000 pointers than to access the database all the time to get data.
I would go straight to use the Redis.
– Leonel Sanches da Silva
@Romaniomorrisonmendez even with multiple users, in several companies and in the same bank ?
– Rod
Sure, without thinking too much.
– Leonel Sanches da Silva