SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Checking the session presence in ASP

We can display a welcome message to a visitor inside a member area based on his session status. If the member has not logged in then we can ask him to login. You must have observed in many sites and forums you will get a welcome message if you are logged in and the same place will show login form or link to login form if you are not logged in. How this is done ? We will learn that.

If the member is logged in then userid of the member will be available in session variable. So we will try to read the value of the session variable and display a welcome message like this

Welcome smo


If session variable is not present then we will display a login window or show a link to login page like his
Userid
Passwor
We will be using one if condition in ASP to check the session and display the welcome message if userid is present , else we will show the login form. Here is the code to do this

<% if (IsEmpty(Session("userid"))) then %>
<form method=post action=loginck.asp>
<table border="0" cellspacing="0" cellpadding="0" align=center>
<tr><td>User Id </td><td><input type=text name=userid></tr>
<tr><td>Password</td><td><input type=password name=password></tr>
<tr><td colspan=2 align=center><input type=submit value=Login></td></tr>
</table>
<%
else


Response.Write " Welcome " & Session("userid") & " <a href=logout.asp>Click here to log out</a>"
End if
%>
You can read similar script on login session management in php here
Further readings
Checking visitor session and displaying login form or welcome message
Login form and data validation using ASP and MsSQL
Allowing access to logged in users inside member area using ASP
Changing Password inside member area using ASP
 
Scripts
PHP
JavaScript
All ASP Tutorials
Popular Tutorials
Managing two drop downs
ASP Tutorials
Date and time
Declaring array
Form in ASP
Server.MapPath
Date Time & MSSQL
Select Query
File System Object
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.