Pls guide me through how to create a login page with session for entire application if the user not using or visiting it will automatically logout using web.config and global.asax with session .
Login Page With Authentication and Session
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Tahir AnsariRank #366 · 6.8K reputationPosted Oct 9, 2023, 11:16 AM EDT
Go through the articles,
https://www.c-sharpcorner.com/UploadFile/009464/how-to-make-a-login-form-using-session-in-Asp-Net-C-Sharp/
https://www.aspsnippets.com/Articles/Implement-Permanent-User-Login-Session-in-ASPNet-using-C-and-VBNet.aspx
Tahir AnsariRank #366 · 6.8K reputationPosted Oct 9, 2023, 11:30 AM EDT
// Example code for authenticating a user and setting a session variable if (IsValidUser(username, password)) // Implement your authentication logic { Session["UserID"] = username; // Store user ID in the session Response.Redirect("WelcomePage.aspx"); // Redirect to a welcome page } else { // Display an error message for invalid credentials }Web.config
Global.asax
protected void Session_Start(object sender, EventArgs e) { // Session started, you can perform any necessary actions here } protected void Session_End(object sender, EventArgs e) { // Session ended (timed out), perform cleanup or logout actions here FormsAuthentication.SignOut(); // Sign out the user Response.Redirect("Login.aspx"); // Redirect to the login page }