Session_OnEnd

B

BillGatesFan

Is there a way to warn the user that there Session is about to end? I'm
using Forms authentication and when there session ends it takes them
back to the login screen like it is designed to do.


Also it there anyway to make it take the user to a different page once
the session ends?


Thanks
 
K

Kevin Spencer

Hi BillGatesFan,
Is there a way to warn the user that there Session is about to end?

Yes. You would have to know the Session Timeout, and add a JavaScript to
each page that uses the JavaScript setTimeout() function to execute a
JavaScript function shortly before the timeout.
Also it there anyway to make it take the user to a different page once
the session ends?

The user may be out playing basketball by the time the Session ends. (IOW,
no)

Let me explain: Session timeout occurs when NO REQUESTS have been made for a
period of (usually) 20 minutes. Without a Request, how can there be a
response?

However, using the technique I described above, you could do a client-side
redirect just prior to the Session timeout. Of course, keep in mind that the
new Request will reset the timeout, and the Session will not end, unless you
call Session.Abandon on the target page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Hi BillGatesFan,

Have a client side script using window.setInterval() method to fire a yes/no
window to fire near the session end time..

SetInterval: Evaluates an expression each time a specified number of
milliseconds has elapsed..
Check this link for more information..
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setinterval.asp

Once the session times out either you can refresh the page and check on the
post back and redirect him to login page or alert him...

Hope this helps..

Need any help, do post a msg back

Happy Coding
 
M

Michael

Add this to every page_load that you want the redirect on timeout to happen

Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) +
10) & ";URL=timeout.aspx")

This will redirect to a page after a specified interval in seconds.

You could also use this method to redirect to a warning page by changing the
'+10' to a '-30', checking that the result is > 0, and the url to your
warning page. In page load of your warning page, set the refresh to redirect
to your login page or some sort of message page when the timeout actually
occurs.

HTH..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top