Asp. NET uses session to determine whether a user is logged in
The following is a reference fragment: if (bresult = = true)//login username and password correct { Save logged in User name session["Loginuser"] = Formatstring.replace (Txtloginuser.text); This is where the session is assigned a value. I have some security handling for the logged-in user. Go to admin Home Response.Redirect ("admin_index.aspx"); } Else { Lblerr.text = Message.show ("Wrong username or password!"); Showvalidate (); Re-display verification code } So how do you decide to log in on the page? The code is simpler, as follows: if (session["loginuser"] = = null)//above session name with Loginuser, the name here to and above the same, you can change, keep the same line, note: session["Loginuser"] behind, No ToString () Oh, if you add it, you'll make a mistake. { Response.Redirect ("Login.aspx"); If the session is empty, go to the landing page. } |