0

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>

Please help me figure out it, thank you!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by punitdam
0

Hi,

There is no need to call session_OnStart anywhere in the application.

If you want to process something on session start. i.e. for example if you want to track no of users logged in, then only you have to write necessary code in Session_OnStart function in global.asa file. So whenever the new session started, Session_OnStart of global.asa file will get called. There is no need to explicitly call Session_OnStart function.

For storing data in session you can directly use without calling Session_OnStart() function as shown below.

<%
session("user") = request.QueryString("user")
response.Write (session("user"))
%>

Edited by punitdam: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.