Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Getting Session Time remaining

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting Session Time remaining

    Is there a way to determine a user's actual session time remaining. Serversetting.session_timeout only gives the max value but I need the countdown of time remaining.

    In v9, I could rely on a variable set on a Submit or an onLoad event to determine the last user activity (database read/update). With v10 and AJAX, users can be active without triggering a Submit or an onLoad event.

    For security reasons, I want users logged out if their session is not in use. But I want to give users on warning before there session expires. I am trying to use a javascript setTimeout() to display a warning before there session ends and they are logged out. The code looks something like this:

    Code:
    <script type="text/javascript"> 
     var c = 555;  //dummy value to prevent premature warning
     function timeoutCheck(){
       if (c<=15){
         // alert user to expiring session
       }
       c =  " <%a5 ?  serversetting.session_timeout %> "   
       //when I check the value of "c" it always shows the session lifetime of 900
       t=setTimeout("timeoutCheck()",5000)  // check the session timeout every 5 seconds.
     }
    </script>
    Is my logic flawed? Is there a better way to do this?

    Thanks, Roberto

    #2
    Re: Getting Session Time remaining

    Hi Roberto, did you find an answer to this? I am also seeing that serversetting.session_timeout only returns the lifetime of 900. Thanks!

    Comment


      #3
      Session Time out

      Is there any function I can use to get how much time is left before a session timeout? I tried using serversetting.session_timeout as Alphapedia says this gives "The number of seconds before a session times out." But this always gives me 900 which is the timeout I have set for the server. Anyone know how I can get the time remaining? Thanks!

      Comment


        #4
        Re: Session Time out

        The amount of time before session timeout is different for each user, depending on their activity. The session time resets to full amount each time they refresh their browser or, on recent versions of A5, if they run any AJAX activity. If you want to warn a person that their session is about to expire, you need a client side javascript routine that will independently count down the seconds, perpahs warn them with an alert 1 minute before.
        Steve Wood
        See my profile on IADN

        Comment


          #5
          Re: Session Time out

          pvin2011, No I have not received an answer to this.

          Steve, How do you know "any" ajax activity resets the session time? Is it possible not all ajax activity resets the session time? It would be preferable to query the application server directly for the user's actual session time remaining.

          Comment


            #6
            Re: Session Time out

            Originally posted by roberto View Post
            Steve, How do you know "any" ajax activity resets the session time? Is it possible not all ajax activity resets the session time? It would be preferable to query the application server directly for the user's actual session time remaining.
            Any activity received from a specific client by the server restarts the session timer on the server for that session. It is not possible to interrogate the server to find out how much time is left for the session, because doing so would reset the timer. As Steve said, you would need to maintain a timer in the client.
            Last edited by Lenny Forziati; 05-20-2011, 01:03 PM.

            Lenny Forziati
            Vice President, Internet Products and Technical Services
            Alpha Software Corporation

            Comment


              #7
              Re: Getting Session Time remaining

              I suspected it was not possible to query the app server for remaining time, but I wanted to be sure. Thanks for the info.

              Comment


                #8
                Re: Getting Session Time remaining

                Steve, How do you know "any" ajax activity resets the session time?
                Because I remember where it was discussed and someone from Alpha, probably Lenny, clarified that it did.

                To answer what you need to do to measure reamining session time, search for "javascript remaining web session timeout" or similar. There are dozens of examples of javascript code - alerts, or a countdown in the status bar, etc.

                I don't know how to do all of this but I think the ideal is:

                1) show a popup alert when the session is about to expire, tell them to click OK to continue
                2) have that OK button do an ajax callback which would reset the session timeout and allow them to continue uninterupted
                3) if they did not click OK by time the session did time out, close the popup, fire the A5 logout function, and send them to a page that says "you were logged out due to inactivity..."

                That seems to be what my bank does.
                Steve Wood
                See my profile on IADN

                Comment


                  #9
                  Re: Getting Session Time remaining

                  I wasn't able to accomplish what you are attempting, but did end up using this idea and it's working well for me:
                  http://javascript.internet.com/page-...-time-out.html
                  Carol King
                  Developer of Custom Homebuilders' Solutions (CHS)
                  http://www.CHSBuilderSoftware.com

                  Comment


                    #10
                    Re: Getting Session Time remaining

                    I just wanted to chime in and post my solution using jQuery and jQuery UI.

                    It basically sets a call for the showDialog javascript function to run after the `time` variable runs out (1.74 million ms is 29 minutes). When the showDialog() function is called it creates a jquery ui dialog that displays nicely. A second timer starts as a countdown for 60 seconds and replaces the text in the #timeout-countdown span every second. If the user click `Yes, Keep Working` then an ajax callback to `keepWorking.a5w` is called. The contents of that file are insignificant, we really just need to ping the WAS to prevent session timeout. After the callback the dialog is closed, and all the timers are reset. If the user clicks `No, Logoff` then the user is forwarded to `logout.a5w` which includes session deletion and the xbasic logout function (also some sql logging stuff). This also happens when the #timeout-countdown time reaches 0.

                    FYI, the WAS session timeout needs to be GREATER than this timeout so that when a user clicks `Yes` or `No` the session is actually still alive. One single second should suffice, but I think my WAS timeout is like 5 minutes longer than the javascript timeout. My thinking for this is that the WAS should NEVER timeout a session itself. I ALWAYS want my logoff.a5w page to be called so I can terminate a session properly and cleanly. I've had quite a few complaints that they come back to the application, type up a bunch of stuff, click save only to find out their session had timed out and they lost all they typed.

                    ALSO, I've already set jQuery to be in no conflict mode with this code
                    Code:
                    var $j = jQuery.noConflict(true);
                    Code:
                    <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css" />
                    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
                    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
                    <!-- Timeout Dialog -->
                    <div id="timeout" style="display:none;" title="Your session is about to expire!">
                    	<p>You will be logged off in <span id="timeout-countdown">60</span> seconds.</p>
                    	<p>Would you like to keep working?</p>
                    </div>
                    <script type="text/javascript">
                            //Timeout dialog
                    
                    	// time = timeout time in milliseconds. 1.74m is 29 minutes
                    	var time = 1740000;
                    	// countdown = time in seconds for the session timeout dialog to show before action is taken.
                    	var timeout = 60;
                    	// logout = the inital set of the showDialog function to show the jquery ui dialog.
                    	var logout = setInterval( function(){showDialog()} , time );
                    	
                    	function showDialog(){
                    
                    		$j('#timeout').dialog({
                    			autoOpen:true,
                    			width: 500,
                    			modal:true,
                    			closeOnEscape:false,
                    			draggable:false,
                    			resizable:false,
                    			buttons: {
                    				'Yes, Keep Working': function(){
                    					// resume once clicked
                    					$j.ajax({
                    						url: "keepAlive.a5w",
                    						cache: false,
                    						success: function(){
                    							//clear and reset the timers
                    							$j('#timeout').dialog('close');
                    							$j('#timeout-countdown').text(timeout);
                    							clearInterval(logout);
                    							clearInterval(timer);
                    							logout = setInterval( function(){showDialog()} , time );
                    						}
                    					});
                    				},
                    				'No, Logoff': function(){
                    					window.location = "logout.a5w";
                    				}
                    			}
                    		});
                    		
                                    // this will countdown starting from the number written in the #timeout-countdown span.
                    		var timer = setInterval(function() {
                    			var countdown = $j('#timeout-countdown').text() || 0;
                    			$j('#timeout-countdown').text(--countdown);
                    			if (countdown == 0){
                    				//timeout! timer hit zero, log the user out.
                    				window.location = "logout.a5w";
                    				clearInterval(timer);
                    			}
                    		}, 1000);
                    
                    	}
                    </script>
                    The positive of using this code instead of Carol's code above is that we don't have to change pages to keep our session active.

                    Comment


                      #11
                      Re: Getting Session Time remaining

                      Hi,
                      Can you tell me where to place these 2 pieces of code in the a5w page?

                      Thanks,
                      Mike
                      Mike Reed
                      Phoenix, AZ

                      Comment


                        #12
                        Re: Getting Session Time remaining

                        It would need to be in the <head> section

                        Comment


                          #13
                          Re: Getting Session Time remaining

                          Hi Sparticuz,
                          Originally posted by Sparticuz View Post
                          It would need to be in the <head> section
                          I am using a TabbedUI as the main page of my application and tried to put this code in the "Header text" property, but it did not work, then tried in the auto-generated TabbedUI.a5w page, but it was erased after a modification to the TabbedUI control, so where exactly can we paste this code?

                          Originally posted by Sparticuz View Post
                          If the user clicks `No, Logoff` then the user is forwarded to `logout.a5w` which includes session deletion and the xbasic logout function (also some sql logging stuff). This also happens when the #timeout-countdown time reaches 0.
                          Also, with a5V11 do we have to delete the session? if so, could you please post a sample code on how to do that?

                          Thanks!!!!
                          Last edited by Progytech; 01-14-2013, 08:09 PM.
                          Edhy Rijo
                          Progytech
                          (Computer Consultants)
                          The makers of CardTracking.Net
                          www.progytech.com

                          Comment


                            #14
                            Re: Getting Session Time remaining

                            Hi all,
                            I found the answers to my question in another posts:

                            For the TabbedUI, I should use the code in the "User defined 'head' content property. Posted by Carol Kind here...

                            And to delete the session, use the session.reset() method in my Logout.a5w page. Posted by Steve Wood here...

                            As always, thanks a lot to the community for the sharing!!!
                            Edhy Rijo
                            Progytech
                            (Computer Consultants)
                            The makers of CardTracking.Net
                            www.progytech.com

                            Comment


                              #15
                              Re: Getting Session Time remaining

                              Hi All,

                              One question, using Sparticuz solution in post 10 above, would it be possible to implement playing a .wav sound file to alert the user when showing the dialog window?

                              I tried to implement this using code from here using my own wav file but it never played out. In this link there is even a test button to play the sound.

                              Code:
                              Dynamic HTML allows you to use JavaScript to write new HTML code into your page and let it be interpreted by the browser. The trick to using dynamic HTML for sound replay is to write into a region of the document the HTML of an embedded sound set to automatically start replay on load. Here we are going to use a <span> region and write into it using its "innerHTML" attribute:
                              
                                  function DHTMLSound(surl) {
                                    document.getElementById("dummyspan").innerHTML=
                                      "<embed src='"+surl+"' hidden=true autostart=true loop=false>";
                                  }
                              
                              We can now create the dummy span region and just pass the URL of the sound file to the function to play it:
                              
                                  <span id=dummyspan></span>
                                  <form>
                                  <input type="button" value="Play Sound" onClick="DHTMLSound('success.wav')">
                                  </form>
                              Edhy Rijo
                              Progytech
                              (Computer Consultants)
                              The makers of CardTracking.Net
                              www.progytech.com

                              Comment

                              Working...
                              X