Session is much simpler than session.
View
Open VB6 and create an ActiveX dll project. Change project name to fcom and class name to fz3
Reference the "Microsoft Active Server Pages object" Object Library.
Create two component events: onstartpage and onendpage
Create a reference of the scriptingcontent class in the event onstartpage.
Instantiation class scriptingcontent.
?
The Code is as follows:
Option explicit
?
'Object Declaration
Dim myresponse as response
Dim myrequest as request
Dim myapplication as application
Dim myserver as server
Dim mysession as session
?
??? 'This event is triggered when the component is created.
Public sub onstartpage (myscriptingcontent as scriptingcontext)
???? 'Instantiate the object
???? Set myresponse = myscriptingcontent. Response
???? Set myrequest = myscriptingcontent. Request
???? Set myserver = myscriptingcontent. Server
???? Set myapplication = myscriptingcontent. Application
???? Set mysession = myscriptingcontent. Session
End sub
?
??? 'This event is triggered when the component is destroyed.
Public sub onendpage ()
???? 'Destroy object
???? Set myresponse = nothing
???? Set myrequest = nothing
???? Set myserver = nothing
???? Set myapplication = nothing
???? Set mysession = nothing
End sub
?
'You can see that the original ASP was moved to VB, and the writing method is the same.
'Get the variables and values of all sessions.
Public sub showsession ()
'Timeout can be set to 20 minutes.
??? Mysession. Timeout = 20
??? Dim myitem
??? 'Get all sessions
??? For each myitem in mysession. Contents
??????? Myresponse. Write myitem & ":" & mysession. Contents (myitem)
??????? Myresponse. Write"
"
??? Next
End sub
?
Test
Open visual interdev6.0 and generate an ASP file
Dim OBJ
Set OBJ = server. Createobject ("fcom. fz3 ")
Session ("name") = "tornado"
Session ("Age") = 26
Session ("special") = "component"
OBJ. showsession ()
%>
?
Configure the virtual directory and execute this ASP file in IE. You can see
Name: tornado
Age: 26
Expertise: Components
?
Session usage is described here. The usage of other sessions is similar.