public ActionResult login(string Username, string Password) { string returnurl = "/Dashboard/index"; bool remeberMe = true; var user = Username; var password = Password;// Password; string username = ""; connectionstring(); con.Open(); com.Connection = con; com.CommandText = "select l.User_id,l.User_name, l.User_email ,ISNULL(l.user_profile,'~/Content/Images/user.png') user_profile, l.Password from Login l where l.User_email='" + user + "' and l.password ='******'"; dr = com.ExecuteReader(); bool status = false; if (dr.Read()) { string u_id = dr["User_id"].ToString(); string u = dr["User_name"].ToString(); string e = dr["User_email"].ToString(); string p = dr["Password"].ToString(); string i = dr["user_profile"].ToString(); if (e == user && p == password) { FormsAuthentication.SetAuthCookie(user, remeberMe); if (Url.IsLocalUrl(returnurl)) { status = true; Session["Username"] = u; Session["U_id"] = u_id; Session["pic"] = i; Session["email"] = e; var sess = Convert.ToInt16(Session["U_id"]); string user_status = 'Y'.ToString(); db.Logoutupdate(sess, DateTime.Today, user_status); } else { status = false; Session["Username"] = null; Session["U_id"] = null; } } con.Close(); } return(new JsonResult { Data = new { status = status, newurl = Url.Action("Index", "Dashboard", new { user_id = Session["U_id"], returnurl = "/Dashboard/index" }) } }); }
public ActionResult Logout() { var sess = Convert.ToInt16(Session["U_id"]); string status = 'N'.ToString(); db.Logoutupdate(sess, DateTime.Today, status); Session.Clear(); Session.Abandon(); Session.RemoveAll(); Session["U_id"] = null; FormsAuthentication.SignOut(); this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); this.Response.Cache.SetCacheability(HttpCacheability.NoCache); this.Response.Cache.SetNoStore(); return(RedirectToAction("index", "Home")); }