Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Session Timeout - javascript

    I am trying to modify a product that we have, to timeout/logoff if page is inactive. Perhaps displaying a pop-up to give warning first.
    The Problem I have is understanding where to put the code & the web page logic,( I am just learning web based apps.. & have had no classes in this..) I have fooled around with different scenarios & have some counters working.
    But simply, 2 scenarios,
    1) The main driver is index.htm, which brings up logon.htm, & then home.htm. from there other pages & a menu can be looked at. Basically, after signing on, I want to go back to logon.htm if user has been inactive...
    If I put my code in index.htm, it affects the logon.htm screen. If I put it in home.htm it only works when on that screen.
    Index.htm has some .js import scripts, I wondering if this is where I need to put this code, or perhaps create a seperate script & call it from index.htm.

    2) also from the logon.htm screen, I want to timeout & close completely after a given time. I have some code in logon.htm that displays a timer, calls a timeout.htm that opens a "yes/no" window. I have a couple bugs.

    Some code I found out here that I am using: in home.htm
    This displays a clock, set at 15 secs, & go backs to logon.htm
    <head>
    <title>Lawson Portal</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <SCRIPT LANGUAGE="JavaScript">
    var href_home = "logon.htm#OUT";

    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);
    if (min == 0 && sec == 0) {
    document.location.href = href_home;
    }
    else down = setTimeout("Down()", 1000);
    }
    function timeIt() {
    min = 1 * Minutes(document.timerform.clock.value);
    sec = 0 + Seconds(document.timerform.clock.value);
    Down();
    }
    </script>
    </head>
    --------------------
    <body tabIndex="-1" onload="init();timeIt()" onunload="unloadFunc()" > etc...
    --------------------
    <right>
    <form name="timerform">
    <input type="text" name="clock" size="7" value=":18"><p>

    </form>
    </right>
    <!-- *cab3 *end -->

    </body>
    ================

    Thank you in advance for any direction....
    CB

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The application server takes care about timed-out sessions. You can specify default timeout value (all sessions) in the server config file or custom (particular session) in a particular page.
    rm -f /

  • #3
    New Coder
    Join Date
    Oct 2005
    Location
    London, United Kingdom
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Remove the init() and unloadFunc() functions and this code will start counting and redirecting.
    Code Review 4U - boost your code and skills for
    being social - JavsScript and C# code reviews.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •