Forms authentication is generally used in internet facing applications. ASP.NET provides easy to use Membership Providers, Role providers etc. But some times we do need to right custom authentication code. That is what we are going to discuss today. Let us start with points to be considered: Note : I am going to use cookie for state management. We need cookie for forms authentication. We need cookie for session management. We need to clear and abandon the session on logout. We need to clear authentication ticket too. Web.config Here we have set the name for the authentication cookie. We have set the loginUrl - URL of the login page. We have set a defaultUrl - URL of the page where the user will be re-directed after login. for other attributes please visit this MSDN page. Authentication On (say) login button click write this code protected void btnLogin_Click(object sender, EventArgs e) { ...