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     
Password

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

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer