Get the number of sessions going on now.

Discussion in 'ASP General' started by Jeff Clark, Nov 13, 2003.

  1. Jeff Clark

    Jeff Clark Guest

    Hiya!
    How would i get this number? thanks!
    Jeff Clark, Nov 13, 2003
    #1
    1. Advertising

  2. www.perfhound.com



    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > Hiya!
    > How would i get this number? thanks!
    >
    >
    Aaron Bertrand - MVP, Nov 13, 2003
    #2
    1. Advertising

  3. Jeff Clark

    Ray at Guest

    Sub Session_OnStart()
    Application.Lock
    Application("SessionCount") = Application("SessionCount") + 1
    Application.Unlock
    End Sub

    Sub Session_OnEnd()
    Application.Lock
    Application("SessionCount") = Application("SessionCount") - 1
    Application.Unlock
    End Sub

    In your global.asa.

    Ray at work


    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > Hiya!
    > How would i get this number? thanks!
    >
    >
    Ray at, Nov 13, 2003
    #3
  4. Jeff Clark

    Jeff Clark Guest

    i love you Ray.

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > Sub Session_OnStart()
    > Application.Lock
    > Application("SessionCount") = Application("SessionCount") + 1
    > Application.Unlock
    > End Sub
    >
    > Sub Session_OnEnd()
    > Application.Lock
    > Application("SessionCount") = Application("SessionCount") - 1
    > Application.Unlock
    > End Sub
    >
    > In your global.asa.
    >
    > Ray at work
    >
    >
    > "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    > news:...
    > > Hiya!
    > > How would i get this number? thanks!
    > >
    > >

    >
    >
    Jeff Clark, Nov 13, 2003
    #4
  5. Careful though, the session_onEnd will not always fire when you expect, if
    at all.
    http://www.aspfaq.com/2078


    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > i love you Ray.
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > Sub Session_OnStart()
    > > Application.Lock
    > > Application("SessionCount") = Application("SessionCount") + 1
    > > Application.Unlock
    > > End Sub
    > >
    > > Sub Session_OnEnd()
    > > Application.Lock
    > > Application("SessionCount") = Application("SessionCount") - 1
    > > Application.Unlock
    > > End Sub
    > >
    > > In your global.asa.
    > >
    > > Ray at work
    > >
    > >
    > > "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    > > news:...
    > > > Hiya!
    > > > How would i get this number? thanks!
    > > >
    > > >

    > >
    > >

    >
    >
    Aaron Bertrand - MVP, Nov 13, 2003
    #5
  6. Jeff Clark

    Ray at Guest

    I love you too Jeff. :]

    Ray at work

    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > i love you Ray.
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > Sub Session_OnStart()
    > > Application.Lock
    > > Application("SessionCount") = Application("SessionCount") + 1
    > > Application.Unlock
    > > End Sub
    > >
    > > Sub Session_OnEnd()
    > > Application.Lock
    > > Application("SessionCount") = Application("SessionCount") - 1
    > > Application.Unlock
    > > End Sub
    > >
    > > In your global.asa.
    > >
    > > Ray at work
    > >
    > >
    > > "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    > > news:...
    > > > Hiya!
    > > > How would i get this number? thanks!
    > > >
    > > >

    > >
    > >

    >
    >
    Ray at, Nov 13, 2003
    #6
  7. Jeff Clark

    Randy Rahbar Guest

    > I love you too Jeff. :]

    Stop guys.. I'm getting teary eyed.
    Randy Rahbar, Nov 13, 2003
    #7
  8. Jeff Clark

    Jeff Clark Guest

    Ray, take my clothes out of the dryer when you get home please

    "Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
    news:...
    > > I love you too Jeff. :]

    >
    > Stop guys.. I'm getting teary eyed.
    >
    >
    Jeff Clark, Nov 13, 2003
    #8
  9. Jeff Clark

    Ray at Guest

    Oh, did you leave them in there again? You know that I hate it when you do
    that! Now I'm going to have to iron them all again. >:|

    Ray at work

    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > Ray, take my clothes out of the dryer when you get home please
    >
    > "Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
    > news:...
    > > > I love you too Jeff. :]

    > >
    > > Stop guys.. I'm getting teary eyed.
    > >
    > >

    >
    >
    Ray at, Nov 13, 2003
    #9
  10. Jeff Clark

    Evertjan. Guest

    Evertjan. wrote on 13 nov 2003 in
    microsoft.public.inetserver.asp.general:

    > Ray at <%=sLocation%> wrote on 13 nov 2003 in
    > microsoft.public.inetserver.asp.general:
    >
    >> Sub Session_OnStart()
    >> Application.Lock
    >> Application("SessionCount") = Application("SessionCount") + 1
    >> Application.Unlock
    >> End Sub
    >>
    >> Sub Session_OnEnd()
    >> Application.Lock
    >> Application("SessionCount") = Application("SessionCount") - 1
    >> Application.Unlock
    >> End Sub
    >>
    >> In your global.asa.
    >>

    >
    > You will need this too, I think:
    >
    > Sub Application_OnStart
    > Application("Active") = 0
    > End Sub



    I mean:

    Sub Application_OnStart
    Application("SessionCount") = 0
    End Sub




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Nov 13, 2003
    #10
  11. Also see the WMI approach.
    http://www.aspfaq.com/2491




    "Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
    news:...
    > Hiya!
    > How would i get this number? thanks!
    >
    >
    Aaron Bertrand - MVP, Nov 13, 2003
    #11
  12. > But it does always fire though (in my experience)...I have used Rays
    technique
    > for over 3 years and at the end of the day, the counter is always zero.


    I've seen cases where it never fired. And remember that you're not always
    checking the counts at the end of the day. :)
    Aaron Bertrand - MVP, Nov 13, 2003
    #12
  13. Jeff Clark

    Ray at Guest

    Do you know in what situations it wouldn't fire? I mean, if you go and kill
    inetinfo.exe or something, it fire then, but as soon as you did that, you'd
    have zero sessions anyway.

    Ray at work

    "Aaron Bertrand - MVP" <> wrote in message
    news:u%...
    > > But it does always fire though (in my experience)...I have used Rays

    > technique
    > > for over 3 years and at the end of the day, the counter is always zero.

    >
    > I've seen cases where it never fired. And remember that you're not always
    > checking the counts at the end of the day. :)
    >
    >
    Ray at, Nov 13, 2003
    #13
  14. Jeff Clark

    Ray at Guest

    That would be, "...it WON'T fire..."

    Ray at work

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > if you go and kill inetinfo.exe or something, it fire then,
    Ray at, Nov 13, 2003
    #14
  15. > Do you know in what situations it wouldn't fire? I mean, if you go and
    kill
    > inetinfo.exe or something, it fire then, but as soon as you did that,

    you'd
    > have zero sessions anyway.


    I don't know the exact circumstance, but I had a site with a session timeout
    of 20 minutes. One time the provider went down, so you couldn't ping the
    box from outside (but I was inside, so could see the database, etc). I had
    code in session_onEnd that cleaned out sessions from the database, and I had
    about 30 active sessions at the time the site went down (easily queried
    right after it happened; I was thinking, "oh crap, how many users did that
    affect?"). I did a query 10 minutes later, and there were still 12 active
    sessions (so 18 of them must have hit session_onEnd). 10 minutes later
    (when all of the session_onEnd() calls should have completed), there were
    still 5. An hour later, there were still 5. IIS was still running, nothing
    had been restarted, etc.

    This actually happened the day before I first wrote the "what is wrong with
    session_onEnd()?" article. And I had no idea how I would be able to figure
    out what was "special" about those 5 sessions; still don't know how I would
    differentiate them if it were to happen today. Also, not sure if this is
    still possible in the IIS 6.0 world; I think that was IIS 5.0 where I
    experienced it.

    Watch the new article about tracking sessions (2491) for the SQL Server
    methodology mentioned in 2078.
    Aaron Bertrand - MVP, Nov 13, 2003
    #15
  16. Jeff Clark

    Ray at Guest

    "Aaron Bertrand - MVP" <> wrote in message
    news:...
    > > Do you know in what situations it wouldn't fire? I mean, if you go and

    > kill
    > > inetinfo.exe or something, it fire then, but as soon as you did that,

    > you'd
    > > have zero sessions anyway.

    >
    > I don't know the exact circumstance, but I had a site with a session

    timeout
    > of 20 minutes. One time the provider went down, so you couldn't ping the
    > box from outside (but I was inside, so could see the database, etc). I

    had
    > code in session_onEnd that cleaned out sessions from the database, and I

    had
    > about 30 active sessions at the time the site went down (easily queried
    > right after it happened; I was thinking, "oh crap, how many users did that
    > affect?"). I did a query 10 minutes later, and there were still 12 active
    > sessions (so 18 of them must have hit session_onEnd). 10 minutes later
    > (when all of the session_onEnd() calls should have completed), there were
    > still 5. An hour later, there were still 5. IIS was still running,

    nothing
    > had been restarted, etc.


    Interesting. Perhaps you should get a better server. :p So, in Jeff's
    particular circumstance, it wouldn't matter, since the application variables
    would be gone anyway, but it certainly does matter if the session_onend
    needs to really do something the way yours was.

    Ray at work
    Ray at, Nov 13, 2003
    #16
  17. > Interesting. Perhaps you should get a better server. :p

    Oh yeah, that was the problem!

    > So, in Jeff's
    > particular circumstance, it wouldn't matter, since the application

    variables
    > would be gone anyway


    I don't follow... can you elaborate? The application variables were not
    gone in my scenario... the server was still running, but session_onEnd did
    not fire for 5 of the 30 sessions. So, application("SessionCount") =
    application("SessionCount") - 1 left application("SessionCount") 5 too high.
    And this was NOT corrected when the server came back online, because the
    only symptom of that was that users could hit the server again (the server
    itself wasn't down; the provider's pipe was down).

    Anyway, I updated http://www.aspfaq.com/2491 with a slightly more reliable
    method using SQL Server (that still, admittedly, can leave sessions to be
    counted as "active" until the timeout, when they really aren't truly
    active... but it will never let a failed session_onEnd permanently spoil the
    count).
    Aaron Bertrand - MVP, Nov 13, 2003
    #17
  18. Jeff Clark

    Ray at Guest

    "Aaron Bertrand - MVP" <> wrote in message
    news:...

    >
    > I don't follow... can you elaborate? The application variables were not
    > gone in my scenario... the server was still running, but session_onEnd did
    > not fire for 5 of the 30 sessions. So, application("SessionCount") =
    > application("SessionCount") - 1 left application("SessionCount") 5 too

    high.
    > And this was NOT corrected when the server came back online, because the
    > only symptom of that was that users could hit the server again (the server
    > itself wasn't down; the provider's pipe was down).


    Yeah, never mind. I was reading it that the server went down. So, I guess
    what I was saying is if you're using Session_OnEnd to update application
    variable and the ~server~ goes down, it doesn't matter about Session_OnEnd
    not updating your app variables, since they'll be gone anyway. But if
    you're relying on Session_OnEnd to make changes outside of IIS, like update
    a database, delete a file, etc., then yeah, it certainly would matter.

    >
    > Anyway, I updated http://www.aspfaq.com/2491 with a slightly more reliable
    > method using SQL Server (that still, admittedly, can leave sessions to be
    > counted as "active" until the timeout, when they really aren't truly
    > active... but it will never let a failed session_onEnd permanently spoil

    the

    Nice. That WMI method is hardcore. Good job.

    Ray at work
    Ray at, Nov 13, 2003
    #18
  19. > Nice. That WMI method is hardcore. Good job.

    Thanks. I guess you can start to imagine the amount of work that went into
    PerfHound, and what a ridiculous bargain it is. :)

    It's too bad that WMI requires an Administrator account to be useful from
    ASP. Though, I suppose it would be trivial to have local VBS scripts update
    a database every so often (more often for volatile information like CPU
    usage, less often for static information like # of CPUs).

    Hey, that gives me an idea...
    Aaron Bertrand - MVP, Nov 13, 2003
    #19
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,344
    Luther Miller
    Aug 8, 2003
  2. Richard
    Replies:
    43
    Views:
    1,808
    Philip Ronan
    Jan 26, 2005
  3. scottymo
    Replies:
    3
    Views:
    678
    Dominick Baier
    Sep 30, 2006
  4. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    543
    Bookham Measures
    Aug 23, 2007
  5. Jim Davidson

    Going nuts with random number routine HELP!

    Jim Davidson, Sep 21, 2003, in forum: Javascript
    Replies:
    3
    Views:
    118
    Dr John Stockton
    Sep 21, 2003
Loading...

Share This Page