The session may end from 10 to 15 minutes on its own, and I want the session to continue as long as the web is open. I want a simplified way through controller
[HttpPost]
public ActionResult Verify(Users acc, string fullname, string roll)
{
DesigenTeemOfMagoubEntities db = new DesigenTeemOfMagoubEntities();
var f_password = HelperClass.EncryptPassword(acc.Password);
var data = db.Users.Where(s => s.Username.Equals(acc.Username) &&
s.Password.Equals(f_password)).ToList();
count = 0;
if (data.Count() > 0)
{
var category = db.Users.Where(s => s.Username == acc.Username).First();
acc.FullName = category.FullName.ToString();
acc.Roll = category.Roll.ToString();
acc.lang = category.lang.ToString();
acc.bransh = category.bransh.ToString();
Session["UserName"] = acc.Username.ToString();
Session["Password"] = HelperClass.EncryptPassword(acc.Password).ToString();
Session["FullName"] = acc.FullName.ToString();
Session["Roll"] = acc.Roll.ToString();
Session["lang"] = acc.lang.ToString();
Session["bransh"] = acc.bransh.ToString();
return RedirectToAction("mob", "Account");
}
else
{
ViewBag.error = "Login failed";
return RedirectToAction("Logincheck");
}
}
CodePudding user response:
You can set the timeout of a session as below in web.config. The default value of the session timeout is 20 minutes.
I suggest you to give a big number. The max number that you can mention is 525,600 minutes (1 year)
. Please refer this for more details about session timeout
<configuration>
<system.web>
<sessionState timeout="20"></sessionState>
</system.web>
</configuration>