In the controller action to which you are POSTing the login form you could verify the credentials against your database and if success emit an authntication cookie which will contain the username of the currently connected user so that you can retrieve it in subsequent actions.
For example assuming you have a form containing a username and password fields which is posting to the LogOn method:
[HttpPost]
public ActionResult LogOn(string username, string password)
{
// TODO: up to you to implement the VerifyCredentials method
if (!VerifyCredentials(username, password))
{
// wrong username or password:
ModelState.AddModelError("", "wrong username or password");
return View();
}
// username and password match => emit an authentication cookie:
FormsAuthentication.SetAuthCookie(username, false);
// and redirect to some controller action which is protected by the
// [Authorize] attribute and which should be accessible only to
// authenticated users
return RedirectToAction("SomeProtectedAction", "SomeController");
}
and inside the protected action you could fetch the currently connected username from the cookie like this:
[Authorize]
public ActionResult SomeProtectedAction()
{
string username = User.Identity.Name;
// TODO: here you could query your database to find out more about
// the user given his username which must be unique
...
}