Forum Moderators: open
Dim xsl, template, processor, strXML, sessionid, xml, starttime1, endtime
sessionid = Request.QueryString("jsessionid")If Application("sessionid") = "" Then
Application("sessionid") = sessionid
starttime1 = Timer()
End If
... lots of code taken out ...
... bottom of script ...
'start email errors
Dim ObjMail, intMailFormat, strSubject
endtime = Timer()
intMailFormat = 1
strSubject = "paging error"
If Not xml Is Nothing Then
If Not xml.documentElement Is Nothing Then
'EXCEPTION IS WHAT WE ARE LOOKING FOR
If xml.documentElement.nodeName = "Exception" Then
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.FROM = "service@favoriteplaces.net"
ObjMail.TO = "mrost@travelnow.com"
ObjMail.Subject = strSubject
ObjMail.BodyFormat = intMailFormat
ObjMail.Body = "This error was generated at request time." & vbcrlf & Request.ServerVariables("HTTP_REFERER") & vbcrlf & Date & vbcrlf & Time & vbcrlf & "Session lasted: " & endtime - starttime1 & vbcrlf & "XML Query:" & vbcrlf & strXML & vbcrlf & vbcrlf & vbcrlf & "XML Response:" & vbcrlf & xmlhttp.responseText
ObjMail.Send
Set ObjMail = Nothing
End If
End If
End If
Set xsl = Nothing
Set xml = Nothing
Set xmlhttp = Nothing
Set template = Nothing
%>
I'm not sure if this is what you are trying to do , but the basic logic is to grab the current time on session start, then access the length of a session at any time by using datediff with the current time.
This code is not checked, ;
sub session_onStart()
session("start")= Now()
end sub
session_seconds = DateDiff("s", Now(),Session("start"))
HTH,
Ross
If it is called on session_onend, i think:) it will be ok becaiuse the event happens just before the session ends.
If it is called by a page, then it should also be ok because every page request has a session created in session onstart.
Is Session_onend reliable? I'm not sure when it is/isnt, maybe someone else can help out here!
<% Response.Buffer=True %>
<%Dim startTime : startTime = Timer()
Dim xsl, template, processor, strXML, sessionid, xml, starttime1, endtime
sessionid = Request.QueryString("jsessionid")
sub session_onStart()
session("start")= Now()
end sub
If Application("sessionid") = "" Then
Application("sessionid") = sessionid
starttime1 = Timer()
End If
'response.write("<!--" & sessionid &"-->")
'If usersession <> 1 Then
'Response.Redirect("error.html")
'End If
Dim carry : carry = Request.QueryString("resType")
If carry = "" Then
Response.Redirect("error.html")
End If
Server.ScriptTimeout = 500
Response.Write("<script language=javascript src=splash_begin.js></script>")
Response.Write("<div id=splashScreen style=position:absolute;z-index:5;top:30%;left:35%;>")
Response.Write("<TABLE align=center BGCOLOR=#000000 BORDER=0 BORDERCOLOR=#000000 CELLPADDING=0 CELLSPACING=0 HEIGHT=200 WIDTH=300>")
Response.Write("<TR>")
Response.Write("<TD WIDTH=100% HEIGHT=100% BGCOLOR=#FFFFFF ALIGN=center VALIGN=MIDDLE>")
Response.Write("<BR/><BR/>")
Response.Write("<FONT FACE=Helvetica,Verdana,Arial SIZE=3 COLOR=#639ACE><B>FavoritePlaces.net is now searching multiple suppliers for the best rates. Please wait...</B></FONT>")
Response.Write("<BR/>")
Response.Write("<IMG SRC=../images/wait.gif BORDER=1 WIDTH=75 HEIGHT=15/><BR/><BR/>")
Response.Write("</TD>")
Response.Write("</TR>")
Response.Write("</TABLE>")
Response.Write("</div>")
Response.Flush
Set xml = Server.CreateObject("microsoft.XMLDOM")
strXML = "http://www.travelnow.com/external/xmlinterface.jsp;jsessionid=" & sessionid &"?cid=56035&resType=" & Request.QueryString("resType") & "&xmlVersion=3&xml=<HotelSessionRequest method='runHotelAvailabilityListQuery'></HotelSessionRequest>"
' Get Code
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",strXML,false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send
response.write("<!--")
response.write(strXML)
response.write("-->")
response.write("<!--")
response.write(xmlhttp.responseText)
response.write("-->")
Set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
xml.async = false
xml.loadXml(xmlhttp.responseText)
Set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
xsl.async = false
xsl.load (Server.MapPath("../xsl/russ.xsl"))
Set template = Server.CreateObject("MSXML2.XSLTemplate")
template.stylesheet = xsl
set processor = template.createProcessor()
processor.input = xml
If usersession <> "" Then
processor.addParameter "usersession", usersession
End If
country = Request.QueryString("country")
If country <> "" Then
processor.addParameter "country", country
End If
arrivalDate = Request.QueryString("arrivalDate")
if arrivalDate <> "" then
processor.addParameter "arrivalDate", arrivalDate
end if
departureDate = Request.QueryString("departureDate")
if departureDate <> "" then
processor.addParameter "departureDate", departureDate
end if
resType = Request.QueryString("resType")
If resType <> "" Then
processor.addParameter "resType", resType
End If
rating = Request.QueryString("rating")
If rating <> "" Then
processor.addParameter "rating", rating
End If
city = Request.QueryString("citysearch")
If city <> "" Then
processor.addParameter "citysearch", city
End If
state = Request.QueryString("statesearch")
If state <> "" Then
processor.addParameter "statesearch", state
End If
processor.transform()
response.flush
response.write("<script language=javascript src=splash_end.js></script>")
Response.Write (processor.output)
Response.Write("<!--")
Response.Write("page generated in:")
Response.Write(Timer() - StartTime)
Response.Write("secs.")
Response.Write("-->")
'start email errors
Dim ObjMail, intMailFormat, strSubject, session_seconds
endtime = Timer()
intMailFormat = 1
strSubject = "paging error"
If Not xml Is Nothing Then
If Not xml.documentElement Is Nothing Then
'EXCEPTION IS WHAT WE ARE LOOKING FOR
If xml.documentElement.nodeName = "Exception" Then
session_seconds = DateDiff("H",Session("start"), Now())
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.FROM = "service@favoriteplaces.net"
ObjMail.TO = "mrost@travelnow.com"
ObjMail.Subject = strSubject
ObjMail.BodyFormat = intMailFormat
ObjMail.Body = "This error was generated at request time." & vbcrlf & Request.ServerVariables("HTTP_REFERER") & vbcrlf & Date & vbcrlf & Time & vbcrlf & "Session lasted: " & session_seconds & vbcrlf & "XML Query:" & vbcrlf & strXML & vbcrlf & vbcrlf & vbcrlf & "XML Response:" & vbcrlf & xmlhttp.responseText
ObjMail.Send
Set ObjMail = Nothing
Call session.abandon
End If
End If
End If
Set xsl = Nothing
Set xml = Nothing
Set xmlhttp = Nothing
Set template = Nothing
response.write("<!--" & session_seconds & "-->")
%>
This error was generated at request time.
http://www.favoriteplaces.net/hotavail.asp
2/28/2003
1:32:15 PM
Session lasted: 904333
XML Query:
http://www.travelnow.com/external/xmlinterface.jsp;jsessionid=iaac74KvrFSd
Gm?cid=56035&resType=hotel&xmlVersion=3&xml=<HotelSessionRequest
method='runHotelAvailabilityListQuery'></HotelSessionRequest>XML Response:
<Exception>
<VERSION>3</VERSION>
<SUPPLIER>0</SUPPLIER>
<LOB>3</LOB>
<SOURCE_TECHNOLOGY>2</SOURCE_TECHNOLOGY>
<FUNCTION>2</FUNCTION>
<CATEGORY>5</CATEGORY>
<HANDLING>2</HANDLING>
<SEVERITY>0</SEVERITY>
<ITINERARYID>-1</ITINERARYID>
<AFFILIATEID>56035</AFFILIATEID>
<EXCEPTION_CONDITIONID>658</EXCEPTION_CONDITIONID>
<DATABASE_MESSAGE>XML AvailList Unable To Process
Request</DATABASE_MESSAGE>
<PRESENTATION_MESSAGE>Query could not be created or located in
session</PRESENTATION_MESSAGE>
<VERBOSE_MESSAGE>Query could not be created or located in
session</VERBOSE_MESSAGE>
</Exception>
Kidding about the pull, of course .... but not about the competition .....hotwire here I come ;)