RenewSession State Before Expiration In .Net 1.1

Discussion in 'ASP .Net' started by WhiskeyRomeo, Jan 15, 2008.

  1. WhiskeyRomeo

    WhiskeyRomeo Guest

    The below appears to be a partial answer to my problem but I don't to keep
    sessions alive simply because a user has wondered off to do something else.
    Session timeout is set to the standard 30 minutes.

    KEEPALIVE.aspx has:
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.AddHeader("Refresh",8000);
    }
    MyRegPage.aspx has:
    <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    frameBorder=no width=0 height=0 runat="server"></IFRAME>

    I am not a JavaScript programmer but have some very basic skills, how can I
    use this solution but add an alert button that pops up at the 17 minute mark
    and if they click Ok the KeepAlive.aspx refreshes. If there is no response
    (by the 20 minute mark) the alert box goes away and is replaced by one that
    says "Your Session has timed out. Go to . . ."

    wr
     
    WhiskeyRomeo, Jan 15, 2008
    #1
    1. Advertising

  2. No, that's not a good approach. Think security, I open several hundred
    connections and now since you allow me to keep those active sessions open,
    I'll eventually cause your server to run out of memory. If the user walks
    away, the session should time out otherwise, they need to be at the
    computer - this long standing design makes sense for a number of different
    reasons and you should stick to it. Having said that, I've done this as well
    but set the app pool to recycle at midnight to 'somewhat' mitigate the
    resource threat. I hope my rambling makes sense to you.

    --

    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The O.W.C. Black Book, 2nd Edition
    Exclusively on www.lulu.com/owc $19.99
    -------------------------------------------------------



    "WhiskeyRomeo" <> wrote in message
    news:...
    > The below appears to be a partial answer to my problem but I don't to keep
    > sessions alive simply because a user has wondered off to do something
    > else.
    > Session timeout is set to the standard 30 minutes.
    >
    > KEEPALIVE.aspx has:
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > Response.AddHeader("Refresh",8000);
    > }
    > MyRegPage.aspx has:
    > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    > frameBorder=no width=0 height=0 runat="server"></IFRAME>
    >
    > I am not a JavaScript programmer but have some very basic skills, how can
    > I
    > use this solution but add an alert button that pops up at the 17 minute
    > mark
    > and if they click Ok the KeepAlive.aspx refreshes. If there is no
    > response
    > (by the 20 minute mark) the alert box goes away and is replaced by one
    > that
    > says "Your Session has timed out. Go to . . ."
    >
    > wr
     
    Alvin Bruney [ASP.NET MVP], Jan 17, 2008
    #2
    1. Advertising

  3. WhiskeyRomeo

    WhiskeyRomeo Guest

    Yes, thanks for replying -- I know it is a bad approach hence the question
    how can I use JavaScript to control it?

    WR

    "Alvin Bruney [ASP.NET MVP]" wrote:

    > No, that's not a good approach. Think security, I open several hundred
    > connections and now since you allow me to keep those active sessions open,
    > I'll eventually cause your server to run out of memory. If the user walks
    > away, the session should time out otherwise, they need to be at the
    > computer - this long standing design makes sense for a number of different
    > reasons and you should stick to it. Having said that, I've done this as well
    > but set the app pool to recycle at midnight to 'somewhat' mitigate the
    > resource threat. I hope my rambling makes sense to you.
    >
    > --
    >
    > Regards,
    > Alvin Bruney [MVP ASP.NET]
    >
    > [Shameless Author plug]
    > The O.W.C. Black Book, 2nd Edition
    > Exclusively on www.lulu.com/owc $19.99
    > -------------------------------------------------------
    >
    >
    >
    > "WhiskeyRomeo" <> wrote in message
    > news:...
    > > The below appears to be a partial answer to my problem but I don't to keep
    > > sessions alive simply because a user has wondered off to do something
    > > else.
    > > Session timeout is set to the standard 30 minutes.
    > >
    > > KEEPALIVE.aspx has:
    > > private void Page_Load(object sender, System.EventArgs e)
    > > {
    > > Response.AddHeader("Refresh",8000);
    > > }
    > > MyRegPage.aspx has:
    > > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    > > frameBorder=no width=0 height=0 runat="server"></IFRAME>
    > >
    > > I am not a JavaScript programmer but have some very basic skills, how can
    > > I
    > > use this solution but add an alert button that pops up at the 17 minute
    > > mark
    > > and if they click Ok the KeepAlive.aspx refreshes. If there is no
    > > response
    > > (by the 20 minute mark) the alert box goes away and is replaced by one
    > > that
    > > says "Your Session has timed out. Go to . . ."
    > >
    > > wr

    >
     
    WhiskeyRomeo, Jan 17, 2008
    #3
  4. I had code for this but I can't find it. Here's how I remember doing it.
    Create a function that pops a message box. Capture the return value from the
    message box click. Let's call that function A. Map your mouse move events to
    another function, let's call that function B. Inside function B, you call
    the javascript clearTimeout and reset the timer with a call to setTimeout.
    When the user is at the computer working the mouse move events will keep
    rescheduling the timer. Inside Function A, you call setTimeout with a
    suitable time and pass in function A so that function A is called after the
    time expires. If the mouse never moves, the timer will run out and the
    function A will be called. Function A should ideally pop an alert box and
    then redirect the user to a login page. The redirection happens after the
    user clicks ok. If the user never comes back the message box remains.
    Settimeout etc
    http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

    --

    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The O.W.C. Black Book, 2nd Edition
    Exclusively on www.lulu.com/owc $19.99
    -------------------------------------------------------



    "WhiskeyRomeo" <> wrote in message
    news:...
    > Yes, thanks for replying -- I know it is a bad approach hence the question
    > how can I use JavaScript to control it?
    >
    > WR
    >
    > "Alvin Bruney [ASP.NET MVP]" wrote:
    >
    >> No, that's not a good approach. Think security, I open several hundred
    >> connections and now since you allow me to keep those active sessions
    >> open,
    >> I'll eventually cause your server to run out of memory. If the user walks
    >> away, the session should time out otherwise, they need to be at the
    >> computer - this long standing design makes sense for a number of
    >> different
    >> reasons and you should stick to it. Having said that, I've done this as
    >> well
    >> but set the app pool to recycle at midnight to 'somewhat' mitigate the
    >> resource threat. I hope my rambling makes sense to you.
    >>
    >> --
    >>
    >> Regards,
    >> Alvin Bruney [MVP ASP.NET]
    >>
    >> [Shameless Author plug]
    >> The O.W.C. Black Book, 2nd Edition
    >> Exclusively on www.lulu.com/owc $19.99
    >> -------------------------------------------------------
    >>
    >>
    >>
    >> "WhiskeyRomeo" <> wrote in message
    >> news:...
    >> > The below appears to be a partial answer to my problem but I don't to
    >> > keep
    >> > sessions alive simply because a user has wondered off to do something
    >> > else.
    >> > Session timeout is set to the standard 30 minutes.
    >> >
    >> > KEEPALIVE.aspx has:
    >> > private void Page_Load(object sender, System.EventArgs e)
    >> > {
    >> > Response.AddHeader("Refresh",8000);
    >> > }
    >> > MyRegPage.aspx has:
    >> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    >> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
    >> >
    >> > I am not a JavaScript programmer but have some very basic skills, how
    >> > can
    >> > I
    >> > use this solution but add an alert button that pops up at the 17 minute
    >> > mark
    >> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
    >> > response
    >> > (by the 20 minute mark) the alert box goes away and is replaced by one
    >> > that
    >> > says "Your Session has timed out. Go to . . ."
    >> >
    >> > wr

    >>
     
    Alvin Bruney [ASP.NET MVP], Jan 17, 2008
    #4
  5. WhiskeyRomeo

    WhiskeyRomeo Guest

    This is all well and good (you are keeping time on the client). But how is
    the session state (on the server) kept alive when the use clicks OK on the
    alert box button? Once a page loads and there is no post for 20 minutes, his
    session should time out. So rather than keeping time via mouse movements, I
    just want to keep time between loading of a page and between postbacks. The
    alert box should pop up at least 3 minutes before session time expires.
    Since I am not going to keep track of session time on the server, I am going
    to assume it starts over on page load or on a post back -- like your
    suggestion says -- and kept a timer on the client.

    If the user clicks OK on the alert box, he should remain on the page he is
    on and an invisible post back happens to keep the session alive.

    WR

    "Alvin Bruney [ASP.NET MVP]" wrote:

    > I had code for this but I can't find it. Here's how I remember doing it.
    > Create a function that pops a message box. Capture the return value from the
    > message box click. Let's call that function A. Map your mouse move events to
    > another function, let's call that function B. Inside function B, you call
    > the javascript clearTimeout and reset the timer with a call to setTimeout.
    > When the user is at the computer working the mouse move events will keep
    > rescheduling the timer. Inside Function A, you call setTimeout with a
    > suitable time and pass in function A so that function A is called after the
    > time expires. If the mouse never moves, the timer will run out and the
    > function A will be called. Function A should ideally pop an alert box and
    > then redirect the user to a login page. The redirection happens after the
    > user clicks ok. If the user never comes back the message box remains.
    > Settimeout etc
    > http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
    >
    > --
    >
    > Regards,
    > Alvin Bruney [MVP ASP.NET]
    >
    > [Shameless Author plug]
    > The O.W.C. Black Book, 2nd Edition
    > Exclusively on www.lulu.com/owc $19.99
    > -------------------------------------------------------
    >
    >
    >
    > "WhiskeyRomeo" <> wrote in message
    > news:...
    > > Yes, thanks for replying -- I know it is a bad approach hence the question
    > > how can I use JavaScript to control it?
    > >
    > > WR
    > >
    > > "Alvin Bruney [ASP.NET MVP]" wrote:
    > >
    > >> No, that's not a good approach. Think security, I open several hundred
    > >> connections and now since you allow me to keep those active sessions
    > >> open,
    > >> I'll eventually cause your server to run out of memory. If the user walks
    > >> away, the session should time out otherwise, they need to be at the
    > >> computer - this long standing design makes sense for a number of
    > >> different
    > >> reasons and you should stick to it. Having said that, I've done this as
    > >> well
    > >> but set the app pool to recycle at midnight to 'somewhat' mitigate the
    > >> resource threat. I hope my rambling makes sense to you.
    > >>
    > >> --
    > >>
    > >> Regards,
    > >> Alvin Bruney [MVP ASP.NET]
    > >>
    > >> [Shameless Author plug]
    > >> The O.W.C. Black Book, 2nd Edition
    > >> Exclusively on www.lulu.com/owc $19.99
    > >> -------------------------------------------------------
    > >>
    > >>
    > >>
    > >> "WhiskeyRomeo" <> wrote in message
    > >> news:...
    > >> > The below appears to be a partial answer to my problem but I don't to
    > >> > keep
    > >> > sessions alive simply because a user has wondered off to do something
    > >> > else.
    > >> > Session timeout is set to the standard 30 minutes.
    > >> >
    > >> > KEEPALIVE.aspx has:
    > >> > private void Page_Load(object sender, System.EventArgs e)
    > >> > {
    > >> > Response.AddHeader("Refresh",8000);
    > >> > }
    > >> > MyRegPage.aspx has:
    > >> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    > >> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
    > >> >
    > >> > I am not a JavaScript programmer but have some very basic skills, how
    > >> > can
    > >> > I
    > >> > use this solution but add an alert button that pops up at the 17 minute
    > >> > mark
    > >> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
    > >> > response
    > >> > (by the 20 minute mark) the alert box goes away and is replaced by one
    > >> > that
    > >> > says "Your Session has timed out. Go to . . ."
    > >> >
    > >> > wr
    > >>

    >
     
    WhiskeyRomeo, Jan 18, 2008
    #5
  6. These are two different clocks unrelated to each other where client clock is
    (server clock - 3min) so that client always times out before server. In your
    case you can, on server click ok, fire an AJAX dummy call.

    > to assume it starts over on page load or on a post back -- like your
    > suggestion says -- and kept a timer on the client.

    Right.

    > the session state (on the server) kept alive when the use clicks OK on the
    > alert box button? Once a page loads and there is no post for 20 minutes,
    > his
    > session should time out. So rather than keeping time via mouse movements,
    > I
    > just want to keep time between loading of a page and between postbacks.
    > The


    Right, but there is no event that fires on the server that allows you to do
    that. If you handle session end, it's too late. There's no
    Session_AbouttoEnd event that is available, although that may be a good
    feature improvement. The only thing that comes to mind is client clock set
    to some value less than the server timeout clock and these two are reset
    with each mouse movement.
    --

    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The O.W.C. Black Book, 2nd Edition
    Exclusively on www.lulu.com/owc $19.99
    -------------------------------------------------------



    "WhiskeyRomeo" <> wrote in message
    news:...
    > This is all well and good (you are keeping time on the client). But how
    > is
    > the session state (on the server) kept alive when the use clicks OK on the
    > alert box button? Once a page loads and there is no post for 20 minutes,
    > his
    > session should time out. So rather than keeping time via mouse movements,
    > I
    > just want to keep time between loading of a page and between postbacks.
    > The
    > alert box should pop up at least 3 minutes before session time expires.
    > Since I am not going to keep track of session time on the server, I am
    > going
    > to assume it starts over on page load or on a post back -- like your
    > suggestion says -- and kept a timer on the client.
    >
    > If the user clicks OK on the alert box, he should remain on the page he is
    > on and an invisible post back happens to keep the session alive.
    >
    > WR
    >
    > "Alvin Bruney [ASP.NET MVP]" wrote:
    >
    >> I had code for this but I can't find it. Here's how I remember doing it.
    >> Create a function that pops a message box. Capture the return value from
    >> the
    >> message box click. Let's call that function A. Map your mouse move events
    >> to
    >> another function, let's call that function B. Inside function B, you call
    >> the javascript clearTimeout and reset the timer with a call to
    >> setTimeout.
    >> When the user is at the computer working the mouse move events will keep
    >> rescheduling the timer. Inside Function A, you call setTimeout with a
    >> suitable time and pass in function A so that function A is called after
    >> the
    >> time expires. If the mouse never moves, the timer will run out and the
    >> function A will be called. Function A should ideally pop an alert box and
    >> then redirect the user to a login page. The redirection happens after the
    >> user clicks ok. If the user never comes back the message box remains.
    >> Settimeout etc
    >> http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
    >>
    >> --
    >>
    >> Regards,
    >> Alvin Bruney [MVP ASP.NET]
    >>
    >> [Shameless Author plug]
    >> The O.W.C. Black Book, 2nd Edition
    >> Exclusively on www.lulu.com/owc $19.99
    >> -------------------------------------------------------
    >>
    >>
    >>
    >> "WhiskeyRomeo" <> wrote in message
    >> news:...
    >> > Yes, thanks for replying -- I know it is a bad approach hence the
    >> > question
    >> > how can I use JavaScript to control it?
    >> >
    >> > WR
    >> >
    >> > "Alvin Bruney [ASP.NET MVP]" wrote:
    >> >
    >> >> No, that's not a good approach. Think security, I open several hundred
    >> >> connections and now since you allow me to keep those active sessions
    >> >> open,
    >> >> I'll eventually cause your server to run out of memory. If the user
    >> >> walks
    >> >> away, the session should time out otherwise, they need to be at the
    >> >> computer - this long standing design makes sense for a number of
    >> >> different
    >> >> reasons and you should stick to it. Having said that, I've done this
    >> >> as
    >> >> well
    >> >> but set the app pool to recycle at midnight to 'somewhat' mitigate the
    >> >> resource threat. I hope my rambling makes sense to you.
    >> >>
    >> >> --
    >> >>
    >> >> Regards,
    >> >> Alvin Bruney [MVP ASP.NET]
    >> >>
    >> >> [Shameless Author plug]
    >> >> The O.W.C. Black Book, 2nd Edition
    >> >> Exclusively on www.lulu.com/owc $19.99
    >> >> -------------------------------------------------------
    >> >>
    >> >>
    >> >>
    >> >> "WhiskeyRomeo" <> wrote in
    >> >> message
    >> >> news:...
    >> >> > The below appears to be a partial answer to my problem but I don't
    >> >> > to
    >> >> > keep
    >> >> > sessions alive simply because a user has wondered off to do
    >> >> > something
    >> >> > else.
    >> >> > Session timeout is set to the standard 30 minutes.
    >> >> >
    >> >> > KEEPALIVE.aspx has:
    >> >> > private void Page_Load(object sender, System.EventArgs e)
    >> >> > {
    >> >> > Response.AddHeader("Refresh",8000);
    >> >> > }
    >> >> > MyRegPage.aspx has:
    >> >> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
    >> >> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
    >> >> >
    >> >> > I am not a JavaScript programmer but have some very basic skills,
    >> >> > how
    >> >> > can
    >> >> > I
    >> >> > use this solution but add an alert button that pops up at the 17
    >> >> > minute
    >> >> > mark
    >> >> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
    >> >> > response
    >> >> > (by the 20 minute mark) the alert box goes away and is replaced by
    >> >> > one
    >> >> > that
    >> >> > says "Your Session has timed out. Go to . . ."
    >> >> >
    >> >> > wr
    >> >>

    >>
     
    Alvin Bruney [ASP.NET MVP], Jan 19, 2008
    #6
    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. Natty Gur
    Replies:
    1
    Views:
    350
    John McDowell
    Aug 7, 2003
  2. jnickfl1
    Replies:
    0
    Views:
    608
    jnickfl1
    Sep 18, 2006
  3. Sergey via DotNetMonster.com

    Why does ASP.NET release cache items before the expiration time?

    Sergey via DotNetMonster.com, Nov 14, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    351
    Sergey via DotNetMonster.com
    Nov 15, 2006
  4. Replies:
    1
    Views:
    137
  5. JT
    Replies:
    2
    Views:
    98
    Aaron [SQL Server MVP]
    Jun 28, 2004
Loading...

Share This Page