please dont rip this site

Session_OnStart

The Session_OnStart event occurs when the server creates a new session. This script is processed prior to executing the requested page. You must set any session-wide variables during the Session_OnStart event. All the built-in objects (Application, Request, Response, Server, and Session) are available and can be referenced in the Session_OnStart event script.

Syntax

<SCRIPT LANGUAGE=ScriptLanguage RUNAT=Server>
Sub Session_OnStart
. . .
End Sub

</SCRIPT>

Parameters

ScriptLanguage

Specifies the scripting language used to write the event script. It may be any supported scripting language, such as Microsoft® Visual Basic® Scripting Edition or JScript™. If more than one event uses the same scripting language, they can be combined under a single set of <SCRIPT> tags.

Remarks

Although the Session object persists if the Session_OnStart event contains a call to the Redirect or End methods, the server stops processing the script in both the Global.asa file and in the file that triggered the Session_OnStart event.

You can call the Redirect method in the Session_OnStart event, for example, to ensure that users always start a session at a particular Web page. When the user enters the application, the server creates a session for that user and processes the Session_OnStart event script. You can include script in this event to check whether the page opened by the user is the starting page and, if not, direct the user to the starting page by calling the Response.Redirect method. This is demonstrated in the following example.

<SCRIPT RUNAT=Server Language=VBScript>
Sub Session_OnStart
    ' Make sure that new users start on the correct
    ' page of the ASP application.

    ' Replace the value given to startPage below
    ' with the virtual path to your application's
    ' start page.

    startPage = "/MyApp/StartHere.asp"
    currentPage = Request.ServerVariables("SCRIPT_NAME")

    ' Do a case-insensitive compare, and if they
    ' don't match, send the user to the start page.
if strcomp(currentPage,startPage,1) then
Response.Redirect(startPage)
end if
End Sub
</SCRIPT>

Note The preceding example only works for browsers that support cookies. Because a noncookie browser does not return the SessionID cookie, the server creates a new session each time the user requests a page. Thus for each request, the server processes the Session_OnStart script and redirects the user to the starting page. If you use the following script, it is recommended that you put a notice on your starting page to inform users that the site requires a cookie-enabled browser.

You should note that any Session_OnStart event script that follows a call to the Redirect method is not executed. For this reason, you should call the Redirect method last in your event script. This is demonstrated in the following example.

<SCRIPT LANGUAGE=VBScript RUNAT=Server> 
   Sub Session_OnStart
      ' Session initialization script  
      Response.Redirect "http:/server/app/StartHere.asp"
   End sub
</SCRIPT>
 

Note In the preceding example the Redirect method hides any text displayed to the client during the session-initialization script.

See Also

Session_OnEnd, Application_OnStart


© Microsoft Corporation. All rights reserved.


file: /Techref/language/asp/obj/global_5.htm, 4KB, , updated: 1996/11/21 18:01, local time: 2024/11/25 17:26,
TOP NEW HELP FIND: 
3.145.177.173:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/asp/obj/global_5.htm"> Session_OnStart</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .