Hi all,
I am developing a web application , which have the log in page with 3 fields(company id, user id & password).
I saw some articles in in the internet for forms authentication , but those articles explaining with user id and password only.
So please tell me or guide or share some links how to use forms authentication with 3 fields.
Thanks
Loading
Satish BhatPosted Aug 19, 2011, 4:58 AM
2] Create a login page with required 3 fields
3] On Login button click do the following.
a] Fetch member details for the company id & user id
If no data found, throw error invalid company id, user id or password
b] If Data found, Match the password (if hashed password is stored, hash the input password and match)
if Everything is ok
string userData = "";
bool isPersistent = false; // If you have remember me checkbox, set accordingly
string username = // UserId from in the input or from the fetched data
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30), isPersistent, userData, FormsAuthentication.FormsCookiePath);
// Encrypt the ticket.
string encTicket = FormsAuthentication.Encrypt(ticket);
// Create the cookie.
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
Response.Redirect(FormsAuthentication.GetRedirectUrl(username, isPersistent));