public IActionResult Login(USER model) { USER user = _manageUser.Login(model); if (user == null) { ViewBag.Error = "Wrong Username or Password"; return(View()); } //save session HttpContext.Session.SetString("Username", user.USERNAME); HttpContext.Session.SetString("Role", user.ROLE); HttpContext.Session.SetString("Name", user.NAME); ViewBag.name = HttpContext.Session.GetString("Name"); //get last time Login in Response.Cookies.Append("LastLoggedInTime", DateTime.Now.ToString()); if (HttpContext.Session.GetString("Role") == "Admin") { return(RedirectToAction("Index", "Admin")); } else if (HttpContext.Session.GetString("Role") == "Payroll") { return(RedirectToAction("Index", "Payroll")); } else if (HttpContext.Session.GetString("Role") == "Human") { return(RedirectToAction("Index", "Human")); } return(View()); }