public ActionResult Login(FormCollection fnLogin) { Int64 PhoneNumber = Convert.ToInt64(fnLogin["txtPhoneNumber"]); Utility en = new Utility(); string PassWord = en.Encrypt(fnLogin["txtPassword"]); // string PassWord = fnLogin["txtPassword"]; InformationServiceWrapper Obj = new InformationServiceWrapper(); UserDetailsModel ModelObj = new UserDetailsModel(); ModelObj = Obj.AdminLoginCheck(PhoneNumber, PassWord); //Create a Cookie with a suitable Key. if (ModelObj.txtUserName != null) { HttpCookie UserNameCookie = new HttpCookie("_RRAUN"); HttpCookie PhoneNumberCookie = new HttpCookie("_RRAPn"); HttpCookie KeyCookie = new HttpCookie("_RRAPS"); //Set the Expiry date. UserNameCookie.Expires = DateTime.Now.AddDays(365); if (ModelObj.txtUserName.Length <= 10) { //Set the Cookie value. UserNameCookie.Values["_RRAUN"] = ModelObj.txtUserName; ViewBag.UserName = ModelObj.txtUserName; //Add the Cookie to Browser. Response.Cookies.Add(UserNameCookie); // Session["LOGGEDONUSER"] = ModelObj.txtUserName; } else { //Session["LOGGEDONUSER"] = ModelObj.txtUserName.Substring(0, 10) + ".."; UserNameCookie.Values["_RRAUN"] = ModelObj.txtUserName.Substring(0, 10) + ".."; //Add the Cookie to Browser. Response.Cookies.Add(UserNameCookie); } if (!string.IsNullOrEmpty((string)UserNameCookie.Value)) { PhoneNumberCookie["_RRAPn"] = fnLogin["txtPhoneNumber"]; KeyCookie["_RRAPS"] = PassWord; } else { ViewBag.ErrorMessage = "Please enter correct credentials"; } return(Json(Convert.ToString(UserNameCookie.Value), JsonRequestBehavior.AllowGet)); } else { return(Json("", JsonRequestBehavior.AllowGet)); } }