I\'m surprised I couldn\'t find any answers.
How do I set my sessionid in my cookie to expire at the end of session? (when the browser closes or the user has been in
Do NOT use Login control, it makes it harder.
protected void btnLogin_Click(object sender, EventArgs e)
{
// Check user and password in database
bool isValidUser = ValidateUser(txtUsername.Text, txtPassword.Text);
// Set cookie to be not persistent - this means if the user closes the browser,
//autentification cookie will be deleted and the user is not longer logged
bool isPersistentCookie = false;
// Login user with the new username
FormsAuthentication.SetAuthCookie(txtUsername.Text, isPersistentCookie);
}