July 2000
Intermediate to advanced
492 pages
14h 53m
English
Session_OnStart —
Session_OnStart
Triggered any time a user who does not already have a session instantiated on the web server requests any page from the server. The code in the OnStart event of the Session object, if it exists, is processed before any code on the requested page.
The OnStart event procedure, if it exists, resides in the GLOBAL.ASA file for the application that contains the requested page.
None
<SCRIPT LANGUAGE = "VBScript" RUNAT = Server> Sub Session_OnStart Dim strSiteStartPage Dim strCurrentPage Dim timUserStartTime Dim strUserIPAddress Dim strUserLogon ' Use the OnStart event to initialize session-level ' variables that your scripts can use throughout the ' the duration of the user's session. Session("timUserStartTime") = Now( ) Session("strUserIPAddress") = _ Request.ServerVariables("REMOTE_ADDR") ' Use the OnStart event to redirect the client if ' she attempts to enter the site from somewhere ' other than the site's home page. strCurrentPage = Request.ServerVariables("SCRIPT_NAME") strSiteStartPage = "/apps/home/startpage.asp" If StrComp(strCurrentPage, strSiteStartPage, 1) Then Response.Redirect(strSiteStartPage) End If ' You can also use the OnStart event of the Session ' object to assess user security access from the very ' beginning of the user's session. Note this code requires ' use of either the Basic authentication or Windows ' NT Challenge Response access control on the web server. strUserLogon = Request.ServerVariables("LOGON_USER") ...Read now
Unlock full access