Approximately minutes remaining in 6 minute session
Classic ASP Active Server Pages Examples, code, tutorials, scriptsASP Examples Menu (below*)

Use ASP with a javascript timer to keep track of minutes left in session until timeout

Want to help users be mindful of time left in session after logged in? One "problem" with a straight javascript timer is that each time the page on which the timer is displayed is reloaded, the timer resets. My little ASP scripting here is a way to carry the current amount of time left in a session over to a timer reload.

On your login processing form, add something like this above the existing session timeout, if any:

Session("STRLOGINTIME")=now() 'this puts the date-time at login into a session variable
Session.Timeout=90 ' if you don't already have a session timeout set...this one would be for 90 minutes. The demo at the top of this page has a 6 min session.

Then, follow the instructions for placement of the following javascript, as found at http://javascript.internet.com/page-details/session-time-out.html  with the small addition of ASP made near the bottom:
min = <%=TimeOnClock%> * Minutes(document.timerform.clock.value);

<html>
<% ' place this ASP code shown here in red, at the top of your header file above the javascript
Session("TIMEexpiredFromSession") = (DateDiff("n",(Session("STRLOGINTIME")),now()))
'this gets how many minutes have passed since login
TimeLeftinSession = (Session.Timeout)-(Session("TIMEexpiredFromSession"))
'this gets how many minutes are remaining in the session
TimeOnClock = TimeLeftinSession/2 
'Get the correct value for the javascript timer
TimeOnClock = FormatNumber(TimeOnClock,0)
'Convert it to a whole number
%>

<head>
<title>Your Page Title</title>


<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore, Editor -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
// Take user here after session timed out
timedouturl = "logout.asp";

function Minutes(data) {
for (var i = 0; i < data.length; i++)
if (data.substring(i, i + 1) == ":")
break;
return (data.substring(0, i));
}
function Seconds(data) {
for (var i = 0; i < data.length; i++)
if (data.substring(i, i + 1) == ":")
break;
return (data.substring(i + 1, data.length));
}
function Display(min, sec) {
var disp;
if (min <= 9) disp = " 0";
else disp = " ";
disp += min + ":";
if (sec <= 9) disp += "0" + sec;
else disp += sec;
return (disp);
}
function Down() {
sec--;
if (sec == -1) { sec = 59; min--; }
document.timerform.clock.value = Display(min, sec);
window.status = "Session will time out in: " + Display(min, sec);
if (min == 0 && sec == 0) {
alert("Your session has timed out.");
//window.location.href = timedouturl;
window.top.location.href =timedouturl;

}
else down = setTimeout("Down()", 1000);

}
function timeIt() {
min =
<%=TimeOnClock%> * Minutes(document.timerform.clock.value);
sec = 0+ Seconds(document.timerform.clock.value);
Down();
}
// End -->
</script>


</head>

<body OnLoad="timeIt()">
<center>
<form name="timerform">
<input type="text" name="clock" size="7" value="2:00"> minutes
remaining before login expires
</form>

<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>

</center>


ASP Examples Menu of Active Server Pages scripts code Classic ASP

Classic ASP Active Server Pages Examples, code, tutorials, scriptsASP Examples Menu (below*)



Active Server Pages | ASP | Scripts | Tutorials | Code | Web Programming | Examples
Active Server Pages ASP code examples, tutorials, and snippets for use in Programming interactive websites.

NOTE: Recently changed hosting and url so some demos aren't working now because I haven't updated pathing; if you find omissions or errors let me know.
 

*

Multiple records per row with paging

Display multiple records per row

Get ID of newly inserted record, Classic ASP, Access Database

Javascript timer with ASP to keep track of time expired until login expires / timeout session is up

Multiple Javascript event functions triggered from single form onsubmit

Get Querystring key names along with querystring variables

ASP Youtube Downloader  Version FOUR
All ASP code. Allows user client side downloads of Youtube videos. You have the option to allow files to be saved directly to your site also.

ASP/PHP video downloader (Works better than ASP for large files)

Use ASP to dynamically parse a Youtube XML playlist to render to html.

Zip up an archive file of your site for backup if you need to restore website with ASP and free Zip Component.

Zip all files in a folder into an archive or backup file dynamically by specific file extension.

Sanitize or clean price cost field for database insertion or display.

Javascript image dimensions and image file size preview.

Put recordset into array, assign keys to the records then use record associated with specific array key as a variable elsewhere.

Access Database Interface Generator Wizard to read your table and field names and to create a table display.

Combining dropdown selection box menu with dynamic ASP database page.

How to redirect user to original page they tried to view before logging, after they are logged in.

Previous/Current/Next Records, or Buddy Ring Script

Custom ASP 404 page not found error script sends visitors to virtual folders

ASP Example: Combine ASP with Javascript for popup windows
dynamically sized to image dimensions.

ASP Example: How to use ASPJPEG to create thumbnails
Click for free Highly recommended thumbnailer for which you don't need Server access

ASPjpeg: How to re-scale aspect ratio of thumbnails by height instead of width.

ASP Example: What if your host has an older version of ASPJPEG that doesn't support gifs?

Using inline frames as "dynamic includes" (offline for updating)

Select Count Distinct Records for Access Database

Upload Image to folder and insert filename into database

Get date in such a way that it can be made part of a file name

Isolate a file name away from its path or extension or strip a path from a file name or strip characters from database field

User-customized on-the-fly stylesheet css files

Enhanced Page Hits Counter (also counts downloads and menu link hits)

Loop through array and compare to string with select case

Aphabetical Paging for your ASP scripts

Web Wiz Guide's Site Searcher Script modified as a file content indexer

Let Users Select How Many Records to View

Access Database for your PayPal IPN scripts

Miscellaneous collected code

You don't have to be a genius, just persistent, to write original Active Server Pages scripts

Software Recommendation: bare_bones_no_bells_and_whistles_asp_code_generator_database_interface_maker

--Lil at gmail.com