Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2007, 08:42 PM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default list session id's and visit time

I IIS, i need to use the Global.asa file and another page named page2.asp to display all the session id's and the time they visited the website.
Im unsure of whether i need to use the session or application object, whether to use variables etc..
So far i have only come up with this, but of course it doesnt work:
Global.asa
Code:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
       sub Application_OnStart()
                DIM sessionStarted()
             sessionStarted= TIME()
             Application("sessionTime") = SessionStarted
       end sub

Server.Transfer("page2.asp")
</SCRIPT>
page2.asp
Code:
<html>
<head>
<title>List of sessions</title>
</head>
<body>
<%
LocalArray = Application("sessionTime")
Response.Write(LocalArray) & "<br />"
%>
</body>
</html>
any help would be muchly appreciated.
 
Old August 22nd, 2007, 09:10 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I would use a DB table and do the insert in the global.asa file. IMO why use the time function, the now function will give you the date time. Depending what you are trying to achieve this gives you much more options for obvious reasons.

Anyhow this is one way to achieve your objective (IMO a much better one. Why not store the values so you can do analysis etc.....):

<script runat=server language=VBScript>
Sub application_onStart

end sub

sub session_onStart
    application.lock
    Set Conn = Server.CreateObject("ADODB.Connection")
    GetConnectionString = "Provider=SQLOLEDB.1; Password=someString; Persist Security Info=True; User ID=someOtherString; Initial Catalog=yourDBName; Data Source=yourPCName"
    Conn.Open GetConnectionString
    SQL = "INSERT INTO sessionStartTime (dt) VALUES('" & now() & "');"
    Conn.execute(SQL)
    Conn.close
     set Conn = nothing
    application.unlock
End Sub

Sub Session_OnEnd

End Sub

Sub Application_OnEnd

End Sub

</script>

Wind is your friend
Matt
 
Old August 22nd, 2007, 09:26 PM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks, that shall be useful.. any ideas how to use the global.asa file though??
 
Old August 22nd, 2007, 09:33 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

That code I posted is a global.asa file

Wind is your friend
Matt
 
Old August 23rd, 2007, 02:32 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mat41
 That code I posted is a global.asa file

Wind is your friend
Matt
oh it is too, sorry, my bad :) thanks for ur help





Similar Threads
Thread Thread Starter Forum Replies Last Post
session time out info nasirmunir PHP How-To 1 August 22nd, 2008 03:07 PM
session time out problem jaya929 ASP.NET 2.0 Professional 2 July 9th, 2008 02:15 AM
session time out lily611 General .NET 10 August 9th, 2004 08:51 AM
unset session at specified time knight Beginning PHP 5 March 17th, 2004 09:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.