ASP Session_OnStart ºÍ Session_OnEnd ʼþ
¶¨ÒåºÍÓ÷¨
Session_OnStart Event
Session_OnStart ʼþÔÚ·þÎñÆ÷´´½¨Ð»Ựʱ·¢Éú¡£
´Ëʼþ·ÅÖÃÔÚ Global.asa ÎļþÖС£
Session_OnEnd Event
Session_OnEnd ʼþÔڻỰ½áÊøÊ±·¢Éú¡£ (»á»°±»·ÅÆú»ò³¬Ê±µÄʱºò).
´Ëʼþ·ÅÖÃÔÚ Global.asa ÎļþÖС£
×¢ÊÍ£ºMapPath ·½·¨²»ÄÜÓÃÔÚ Session_OnEnd ´úÂëÖС£
Óï·¨
<script language="vbscript" runat="server"> Sub Session_OnStart . . . End Sub Sub Session_OnEnd . . . End Sub </script>
ʵÀý
Global.asa:
<script language="vbscript" runat="server"> Sub Application_OnEnd() Application("totvisitors")=Application("visitors") End Sub Sub Application_OnStart Application("visitors")=0 End Sub Sub Session_OnStart Application.Lock Application("visitors")=Application("visitors")+1 Application.UnLock End Sub Sub Session_OnEnd Application.Lock Application("visitors")=Application("visitors")-1 Application.UnLock End Sub </script>
ÔÚ ASP ÎļþÖÐÏÔʾµ±Ç°µÄ·Ã¿ÍÊý£º
<html> <head> </head> <body> <p> There are <%response.write(Application("visitors"))%> online now! </p> </body> </html>