I've tried searching how to accomplish this, but everything I can find seems too complicated and comprehensive that I can't really grasp how it works. The following is my situation:
I've got a simple MySQL table called users with three attributes: user_id, username and password.
In ASP.NET page I've got two textboxes and a login-button.
I've read that I could use FormsAuthentication, but I haven't been able to figure out how it works. Do I have to use "Membership"? Or can I use FormsAuthentication without that? I would prefer just to have it as simple as possible.
So far, I simply make a select like this:
String query = "SELECT * FROM users WHERE username = @UserName
AND password = @Password;";
cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@UserName", userName);
cmd.Parameters.AddWithValue("@Password", password);
In my code-behind I have this:
String username = txtUsername.Text;
String password = txtPassword.Text;
User user = database.LogIn(username, password);
And finally in my web.config file I have this:
<authentication mode="Forms">
<forms name="MyCookieName"
loginUrl="~/Default.aspx"
timeout="10"
protection="All"
path="/">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
So far I can validate whether or not the user has entered valid input, but I don't understand how I can apply the FormsAuthentication. Any help is appreciated.