473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Warning that Session about to Timeout

Got a web app that keeps the 20 sec session timeout default. Only deal is
the user doesn't know the session timed out till they submit the page. On
one page that i actually don't care if it times out i have a meta tag that
refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that
the screen has timed out that will stay visible til the user clicks OK......

What's the best way to acheive this result?

Thanks
Harry
Nov 18 '05 #1
8 4500
Use a JavaScript function in the page that waits 15 minutes and pops up an
alert box.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only deal is
the user doesn't know the session timed out till they submit the page. On
one page that i actually don't care if it times out i have a meta tag that
refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that
the screen has timed out that will stay visible til the user clicks OK......
What's the best way to acheive this result?

Thanks
Harry

Nov 18 '05 #2
I've used a session variable that I check for in the page load, if it is not
there, then its timed out.
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only deal is
the user doesn't know the session timed out till they submit the page. On
one page that i actually don't care if it times out i have a meta tag that
refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that
the screen has timed out that will stay visible til the user clicks OK......
What's the best way to acheive this result?

Thanks
Harry

Nov 18 '05 #3
Suppose that's the only way to do it. Are you writing it in the html or
doing the registerscriptblock?

I'll search my Javascript book for some code to piece together.

Thanks!

Harry
MCSD

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
Use a JavaScript function in the page that waits 15 minutes and pops up an
alert box.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only deal is the user doesn't know the session timed out till they submit the page. On one page that i actually don't care if it times out i have a meta tag that refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that the screen has timed out that will stay visible til the user clicks

OK......

What's the best way to acheive this result?

Thanks
Harry


Nov 18 '05 #4
The kicker is I want the user to be warned on an already loaded page. On
postback i'll know a session has timed out immediately.
"Felbrigg" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I've used a session variable that I check for in the page load, if it is not there, then its timed out.
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only deal is the user doesn't know the session timed out till they submit the page. On one page that i actually don't care if it times out i have a meta tag that refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that the screen has timed out that will stay visible til the user clicks

OK......

What's the best way to acheive this result?

Thanks
Harry


Nov 18 '05 #5
Hi Harry,

Let me save you some trouble. You need to use the JavaScript setTimeOut()
function. Define a function that pops up the alert box, and use setTimeOut()
to set the delay. It takes 2 parameters, the function name, and the number
of milliseconds to wait. Here's an example:

<script type="text/javascript><!--
function SessionAlert()
{
alert("Your Session will time out in 5 minutes");
}
setTimeOut("SessionAlert", 15 * 60 * 1000);
// --></script>

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:#l**************@TK2MSFTNGP12.phx.gbl...
Suppose that's the only way to do it. Are you writing it in the html or
doing the registerscriptblock?

I'll search my Javascript book for some code to piece together.

Thanks!

Harry
MCSD

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
Use a JavaScript function in the page that waits 15 minutes and pops up an
alert box.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only
deal is the user doesn't know the session timed out till they submit the page. On one page that i actually don't care if it times out i have a meta tag that refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that the screen has timed out that will stay visible til the user clicks

OK......

What's the best way to acheive this result?

Thanks
Harry



Nov 18 '05 #6
Intresting idea. But why warn them what are they going to do. In my
systems I redirect them to the login page and give them a message telling
them why.
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
The kicker is I want the user to be warned on an already loaded page. On
postback i'll know a session has timed out immediately.
"Felbrigg" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I've used a session variable that I check for in the page load, if it is not
there, then its timed out.
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only
deal is the user doesn't know the session timed out till they submit the page. On one page that i actually don't care if it times out i have a meta tag that refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that the screen has timed out that will stay visible til the user clicks

OK......

What's the best way to acheive this result?

Thanks
Harry



Nov 18 '05 #7
I have a better solution than a warning.
What about session that never times out if user has his browser window open.

Here is what i am doing

1. Somewhere on each page (usually in a footer ) i have <img
src="/transparent.gif" name="renewSession" width="1" height="1">

2. Also each page has a following javascript.
<script language="Javascript">
window.setInterval("renewSession()", 600000);

function renewSession()
{
document.images("renewSession").src = "/renewSession.aspx?par=" +
Math.random();
}
</script>

3. Have a renewSession.aspx which outputs the transparent gif 1x1 pixel.

Done. Notice that you need Math.random() to prevent caching. Also in
renewSession.aspc use Response.Expires = -1.

You can easily create UserControl which implements all that and make that
control as a part of your header, footer,... what ever you have on each
page.
George.

"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only deal is
the user doesn't know the session timed out till they submit the page. On
one page that i actually don't care if it times out i have a meta tag that
refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that
the screen has timed out that will stay visible til the user clicks OK......
What's the best way to acheive this result?

Thanks
Harry

Nov 18 '05 #8
Thanks to all who responded!!

I do want the session to expire if not used but i also want the user to be
aware that is what's happening before they enter a lot of stuff and submit.
Here's the code i came up with that works well:

function warnuser()
{
if (confirm("There has been no activity for some time.\nClick 'OK' if you
wish to continue your session,\nor click 'Cancel' to log out.\nFor your
security if you are unable to respond to this message\nwithin 2 minutes you
will be logged out automatically."))
{
//post the page to itself
document.location.href = "Utilities.aspx"
}
else
{
document.location.href = "Default.aspx"
}
}

then in the body tag:
onload=setTimeout("warnuser()",1080000)

Harry
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
The kicker is I want the user to be warned on an already loaded page. On
postback i'll know a session has timed out immediately.
"Felbrigg" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I've used a session variable that I check for in the page load, if it is not
there, then its timed out.
"Harry Simpson" <hs*******@nospamphgt.net> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...
Got a web app that keeps the 20 sec session timeout default. Only
deal is the user doesn't know the session timed out till they submit the page. On one page that i actually don't care if it times out i have a meta tag that refreshes at about 18 minutes so the screen never times out.

On the other pages that i want to time out, i'd like to pop a warning that the screen has timed out that will stay visible til the user clicks

OK......

What's the best way to acheive this result?

Thanks
Harry



Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jenna | last post by:
Hi all, Do you know how to reset session.timeout after user click to extend the session timeout? For example, default session.timeout is 20 mins and 2 mins before will ask whether extend...
12
by: Geigho | last post by:
Setting session timeout in web.config file does not seem to have any effect. Any explanation or suggestion will be appreciated.
4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
8
by: Joe Abou Jaoude | last post by:
hi, I have a web app with forms authentication and a timeout session of 20 mins for security reasons. I recently added a feature that allows users (if they want to) to automatically log in...
11
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
6
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.