PDA

View Full Version : Using session to track the user who logged in


thebluestar136
05-23-2010, 10:21 AM
I have tried to use session to track/ say 'Hello' to the user who is online.
However, I'm very new to use this object and actually, I'm still not clear all about the global.asa file. I mean we write all methods about sessions we'll in it , then call it in the asp file.
Sometimes, to start session, we have to start application first. I'm not clear about this, you can explain it for me? thank you!
and here is my source code:
(I have just made an example to try, it's not enough)
loginForm.asp
<html>
<body>

<form method="post" action="login.asp">
<p>Username:
<input type="text" name="user">
</p>
<p> Password:
<input type="password" name="pass">
</p>
<p>
<input type="submit" name="submit" value="Sign in">
<br>
</p>
</form>
</body>
</html>
login.asp<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Xin chao,
<%
session_OnStart()
'response.Write (session("started"))
session("user") = request.QueryString("user")
response.Write (session("user"))
%>
</body>
</html>