Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ProcessRequest (HttpContext context)
- {
- string Message = "";
- try
- {
- string EmailId = HttpContext.Current.Request["emailid"].ToString();
- string Password = HttpContext.Current.Request["Password"].ToString();
- string User = "";
- Entities.UserTable user = null;
- UserDAL userDAL = new UserDAL();
- user = userDAL.UserLogin(EmailId, Password);
- if (user != null)
- {
- int userId = user.Id;
- string roles = "User";
- bool rememberUserName = true;
- FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
- 1, // Ticket version
- user.Id.ToString(),// Username to be associated with this ticket
- DateTime.Now, // Date/time ticket was issued
- DateTime.Now.AddYears(20), // Date and time the cookie will expire
- rememberUserName, // if user has chcked rememebr me then create persistent cookie
- roles, // store the user data, in this case roles of the user
- FormsAuthentication.FormsCookiePath); // Cookie path specified in the web.config file in <Forms> tag if any.
- string hashCookies = FormsAuthentication.Encrypt(ticket);
- HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies); // Hashed ticket
- cookie.Expires = DateTime.Now.AddYears(20);
- HttpContext.Current.Response.Cookies.Add(cookie);
- Message = "success";
- }
- else
- {
- Message = "Please check your Mailid or password.";
- }
- }
- catch(Exception ex)
- {
- Message = "Please contact Support";
- }
- context.Response.ContentType = "text/plain";
- context.Response.Write(Message);
- }
Add Comment
Please, Sign In to add comment