Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 20th, 2004, 07:56 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default Global.asa File Help

Hello! This is my code from my Global.asa file:

Code:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Application_OnStart
    ' Set our user count to 0 when we start the server
    Application("ActiveGuests") = 0
End Sub

Sub Session_OnStart
    ' Change Session Timeout to 20 minutes (if you need to)
    Session.Timeout = 3
    ' Set a Session Start Time
    ' This is only important to assure we start a session
    Session("Start") = Now
    ' Increase the active visitors count when we start the session
    Application.Lock
        Application("ActiveGuests") = Application("ActiveGuests") + 1
    Application.UnLock
End Sub

Sub Session_OnEnd
    ' Decrease the active visitors count when the session ends.
    Application.Lock
        Application("ActiveGuests") = Application("ActiveGuests") - 1
    Application.UnLock
End Sub

</SCRIPT>
I want the ActiveGuests count to be as up to date as possible. So instead of waiting 3 minutes from the time the user closes the window, I would like it to be updated as soon as the window from my website was closed. And Session_OnEnd does not do that, or as far as I know. if anyone knows how to do this, PLEASE reply... It would REALLY help. THanks a lot!

 
Old September 20th, 2004, 08:30 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Setting a session timeout to 3 minutes is dangerous especialy if you use ANY session vars throughout your site.

call a session.abandon() when the window closes will make the sesison_onEnd finish instantly

Wind is your friend
Matt
 
Old September 20th, 2004, 08:45 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

Sorry to bother you, but how would you detech that the window closes in ASP?

 
Old September 20th, 2004, 09:20 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default


Hello,

  In the <body onunload="unld()">

<script language="javascript">
function unld(){
    var op=window.open("sessionabandonpage","wdwname","wid th=50,height=50");
}
</script>

In the sessionabandonpage,

<%
   session.abandon()
%>

<body onload="cls()">
<script language="javascript">
function cls(){
   window.close();
}
</script>

I didnt test this. Try this...

--------
Rajani

 
Old September 21st, 2004, 02:42 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

Is there a way to do this without poping up a window?


 
Old September 21st, 2004, 05:56 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

The way suggested above will work, adding:

<script language = JavaScript>
  self.close();
</script>

Beneath the session.abandon function will do it. I would be more inclined to; inside the function unld() (as suggested above) instead of using a new window function, simply submit a hidden form to the sessionabandonpage. either way will work

Wind is your friend
Matt
 
Old September 21st, 2004, 08:30 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

See the only problem with that, is if the user has a popup blocker (that almost everyone has now) it will not be able to run the session.abandon function.

 
Old September 21st, 2004, 10:35 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

pop up blokers dont block new windows that have been fired from an event

I dont have a pop up blocker installed at present (I tend to watch the types of web sites I go to). However, I used to have pop up cop - this did not stop new window functions from poping up on sites I were developing or have developed.

Any how as I said in a previous post;
;;;I would be more inclined to; inside the function unld() (as suggested above) instead of using a new window function, simply submit a hidden form to the sessionabandonpage.

Wind is your friend
Matt
 
Old September 22nd, 2004, 04:03 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

Anyone have a example of that?


 
Old September 22nd, 2004, 06:33 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Note: the ; has been left out in rajanikrishna's post, it should be:
<body onunload="unld();">

Somewhere on your page place (you can have as many forms on a page as you like):
<FORM NAME="updateForm" METHOD="Post" ACTION="sessionabandonpage.asp">
 <input type="hidden" name="someName" value="anyValueYouNeedToPass">
</form>

Then after the <head> and before the </head> put:
  <SCRIPT LANGUAGE="Javascript">
     function unld()
     {
        updateForm.submit();
     }
  </script>

The above code implimented will, onUnload jump into the function, submit it's self to the location specified in the action value of the <form> tag - job done. You may pass as many values the the destination page as you like via hidden form fields and or the function in the body tag



Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Are functions allowed in global.asa file mat41 Classic ASP Basics 1 January 10th, 2008 01:58 AM
how to include file in global.asa beetle_jaipur Classic ASP Basics 1 April 18th, 2006 03:46 AM
Debugging Global.asa file arimakidd Classic ASP Professional 1 August 23rd, 2005 03:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.