Checking login Session state in Classic ASP

Pages can change their navigation or welcome message according to whether an authenticated user ID exists in Session. This is a presentation check; protected pages must still enforce authorization independently.

Example signed-in output

Welcome smo

Example login controls

<input type="text" name="userid">
<input type="password" name="password">

Switch the display using Session state

<% If IsEmpty(Session("userid")) Then %>
  <a href="lg-login.php">Log in</a>
<% Else %>
  Welcome <%= Server.HTMLEncode(Session("userid")) %>
  <a href="logout.asp">Log out</a>
<% End If %>

HTML-encode the Session value before displaying it. The login processing page should be responsible for validating credentials and creating Session("userid"); this page only reads that established state.


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer