Session Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Olurotimi Ige

    Session Question

    I'm tracking usersOnline by adding this code below in my Global.asax
    file.But i noticed that when a user logs in it keeps adding a new user
    which thats fine..but when a user logs of it still retains the
    user(session) for sometime instead of reducing it by one!

    I'm thinking of maybe i should change something in IIS relating to
    Session?

    Any ideas..


    Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
    ' Fires when the session is started
    Session("Start" ) = Now
    Application.Loc k()
    Application("Ac tiveUsers") = CInt(Applicatio n("ActiveUsers" )) +
    1
    Application.UnL ock()
    End Sub

    --------------------------
    Sub Session_End(ByV al sender As Object, ByVal e As EventArgs)
    ' Fires when the session ends
    Application.Loc k()
    Application("Ac tiveUsers") = CInt(Applicatio n("ActiveUsers" )) -
    1
    Application.UnL ock()
    End Sub



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Steve C. Orr [MVP, MCSD]

    #2
    Re: Session Question

    By default a session ends after 20 minutes of no page requests from the
    user.
    That would be when the Session_End event normally fires.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP



    "Patrick Olurotimi Ige" <patrick.ige@cr azyjohns.com.au > wrote in message
    news:%23aPYKuW4 EHA.2452@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    > I'm tracking usersOnline by adding this code below in my Global.asax
    > file.But i noticed that when a user logs in it keeps adding a new user
    > which thats fine..but when a user logs of it still retains the
    > user(session) for sometime instead of reducing it by one!
    >
    > I'm thinking of maybe i should change something in IIS relating to
    > Session?
    >
    > Any ideas..
    >
    >
    > Sub Session_Start(B yVal sender As Object, ByVal e As EventArgs)
    > ' Fires when the session is started
    > Session("Start" ) = Now
    > Application.Loc k()
    > Application("Ac tiveUsers") = CInt(Applicatio n("ActiveUsers" )) +
    > 1
    > Application.UnL ock()
    > End Sub
    >
    > --------------------------
    > Sub Session_End(ByV al sender As Object, ByVal e As EventArgs)
    > ' Fires when the session ends
    > Application.Loc k()
    > Application("Ac tiveUsers") = CInt(Applicatio n("ActiveUsers" )) -
    > 1
    > Application.UnL ock()
    > End Sub
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • Patrick Olurotimi Ige

      #3
      Re: Session Question

      Thx Steve..
      So it means if i change the Session Timeout in Web.Config to a lower
      value it should be fine?

      And another question which one overrides Session timeout in Web.Config
      or IIS..




      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Juan T. Llibre

        #4
        Re: Session Question

        re:[color=blue]
        > So it means if i change the Session Timeout in
        > Web.Config to a lower value it should be fine?[/color]

        Yes.
        It would also be fine if you change it to a higher value.

        re:[color=blue]
        > which one overrides Session timeout
        > in Web.Config or IIS..[/color]

        Web.config overrides.



        Juan T. Llibre
        ===========
        "Patrick Olurotimi Ige" <patrick.ige@cr azyjohns.com.au > wrote in message
        news:e1sQG8W4EH A.824@TK2MSFTNG P11.phx.gbl...[color=blue]
        > Thx Steve..
        > So it means if i change the Session Timeout in Web.Config to a lower
        > value it should be fine?
        >
        > And another question which one overrides Session timeout in Web.Config
        > or IIS..[/color]


        Comment

        • Patrick Olurotimi Ige

          #5
          Re: Session Question

          Thx Juan for the reply..
          Setting the value to higher level or lower level ..
          Which one best fits for tracking UsersOnline?




          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Steve C. Orr [MVP, MCSD]

            #6
            Re: Session Question

            Lower would be more accurate for tracking users online, but it might annoy
            your users if you set it too low.

            --
            I hope this helps,
            Steve C. Orr, MCSD, MVP



            "Patrick Olurotimi Ige" <patrick.ige@cr azyjohns.com.au > wrote in message
            news:etReUHX4EH A.1204@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Thx Juan for the reply..
            > Setting the value to higher level or lower level ..
            > Which one best fits for tracking UsersOnline?
            >
            >
            >
            >
            > *** Sent via Developersdex http://www.developersdex.com ***
            > Don't just participate in USENET...get rewarded for it![/color]


            Comment

            • Juan T. Llibre

              #7
              Re: Session Question

              re:[color=blue]
              > Setting the value to higher level or lower level ..
              > Which one best fits for tracking UsersOnline?[/color]

              That would depend on your user's needs
              or on your website's needs.


              Tracking sessions consumes server resources
              ( memory and processing time, for the most part ).

              If you need to track user information to such
              an extent that you need a longer session level.
              then increasing it would make sense.

              Otherwise, increasing the session time
              would be a waste of server resources.

              You should strive for the least session time value
              which serves your user/server needs.



              Juan T. Llibre
              ===========
              "Patrick Olurotimi Ige" <patrick.ige@cr azyjohns.com.au > wrote in message
              news:etReUHX4EH A.1204@TK2MSFTN GP10.phx.gbl...[color=blue]
              > Thx Juan for the reply..
              > Setting the value to higher level or lower level ..
              > Which one best fits for tracking UsersOnline?[/color]


              Comment

              Working...