Exemple #1
0
 /// <summary>
 /// Used to set the User Information in cookie
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public static HttpCookie SetUserInfoCookie(Login userInfo)
 {
     var userInfoCookie = new HttpCookie("USER_INFORMATION");
     userInfoCookie["LoginUserName"] = userInfo.UserName;
     userInfoCookie["LoginPassword"] = userInfo.Password;
     userInfoCookie["RememberMe"] = userInfo.RememberMe ? "true" : "false";
     userInfoCookie.Expires = DateTime.Now.Add(new TimeSpan(10, 0, 0, 0));
     return userInfoCookie;
 }
        public ActionResult NewsIndiaAdminLogin(Login loginInfo)
        {
            if (ModelState.IsValid)
            {
                var userInfo = Account.GetLoginInfo(new LoginInfo() { Password = loginInfo.Password, UserName = loginInfo.UserName });

                if (userInfo != null)
                {
                    SessionManager.SetSessionInfo(userInfo);
                    if (loginInfo.RememberMe)
                        Response.Cookies.Add(CookieManager.SetUserInfoCookie(loginInfo));
                    else
                        CookieManager.ClearCookie(Request, Response.Cookies);

                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", "Invalid Username or Password.");
                }

            }
            return View(loginInfo);
        }