for the login try the following code
if (Membership.ValidateUser(UserName.Text, Password.Text))
{
FormsAuthentication.SetAuthCookie(UserName.Text, RememberMe.Checked);
}
else
{
MembershipUser user = Membership.GetUser(UserName.Text);
if (user == null)
{
LoginError.Text =
string.Format(Resources.Generic.USERS_ERROR_NOUSER, UserName.Text);
}
else
{
if (!user.IsApproved)
{
LoginError.Text = Resources.Generic.USERS_ERROR_NOT_APPROVED;
}
else if (user.IsLockedOut)
{
LoginError.Text = Resources.Generic.USERS_ERROR_LOCKED_OUT;
}
else
{
LoginError.Text = Resources.Generic.USERS_ERROR_GENERIC;
}
}
}
Where UserName and Password are the textboxs containing the username and password.
Meanwhile for logout try
FormsAuthentication.SignOut();
Cheers