Name

Session_OnStart — Session_OnStart

Synopsis

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.

Parameters

None

Example

<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") ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.