473,383 Members | 1,872 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,383 software developers and data experts.

Session Timeout Popup(before 2 mints session expired one popup will come and will ask

i am having problem with my site when user is idle for some time then before 3 mints session getting expired one popup will come and will ask if you want to renew your session then click ok or else cancel.so when i am clicking on ok we are getting response from the server but after that we are not able to click any of the link.
could you please help me out. Thank In Advance.
Expand|Select|Wrap|Line Numbers
  1. var alertDuration;
  2. var sessionTimeoutDuration;
  3. var alertTime;
  4. var isIE8 = window.XDomainRequest ? true : false;
  5. function startTimer(){
  6.     //Configure the parameters to Timeout to change
  7.     //  i.  session timeout duration (currently set to 30 minutes) and
  8.     //  ii. time before session timeout the user should be alerted (set to 3 minutes)
  9.     timer = new Timeout(5,3);
  10.     timer.start();
  11. }
  12.  
  13. function Timeout(std,ad){
  14.     sessionTimeoutDuration = std;
  15.     alertDuration = ad;
  16.     alertTime = ((sessionTimeoutDuration * 60 * 1000) - (alertDuration * 60 * 1000));
  17. }
  18.  
  19. Timeout.prototype.cookieString = "sessionexpiry=";
  20. Timeout.prototype.confirmDisplayed = "confirmDisplayed=";
  21. Timeout.prototype.renewURL = "../../pages/ceppages/renew.iface";
  22. Timeout.prototype.logoutURL = "../../pages/ceppages/logout.jsp";
  23. Timeout.prototype.sessionTimeOutURL = "../../pages/ceppages/logout.jsp";
  24.  
  25. Timeout.prototype.start = function(){
  26.     var currentPage = window.location;
  27.     //do not run if the call happens from the logout page
  28.     if((currentPage.toString()).indexOf(this.logoutURL) != -1){
  29.         return;
  30.     }
  31.     //reset flag
  32.     document.cookie = this.confirmDisplayed + "false";
  33.     var ms = new Date().getTime() + alertTime;
  34.     document.cookie = this.cookieString + encodeURIComponent(ms);
  35.     //create a random integer between 10 & 20
  36.     var interval = (Math.floor(Math.random() * 10)) + 10;
  37.     timer = window.setInterval("Timeout.prototype.check()",interval * 1000);
  38. }
  39.  
  40. Timeout.prototype.stop = function(){
  41.     //Not implemented at this time. 
  42. }
  43. Timeout.prototype.check = function(){
  44.     if(this.isConfirmDisplayed() == "true"){
  45.         return;
  46.     }
  47.     var expTime = this.getExpiryTime();
  48.     var now = new Date().getTime();
  49.     if(now >= expTime){
  50.         document.cookie = this.confirmDisplayed + "true";
  51.         var choice = this.displayConfirm(expTime);
  52.         if(choice){
  53.             alert("extending session!!");
  54.             this.extendSession();
  55.         }else{
  56.             this.logout();
  57.         }
  58.     }
  59. };
  60. Timeout.prototype.isConfirmDisplayed = function(){
  61.     var cookies = document.cookie;
  62.     var position = cookies.indexOf(this.confirmDisplayed);
  63.     if(position != -1){
  64.         var end = cookies.indexOf(";",position);
  65.         if(end == -1){end = cookies.length};
  66.         var conDisp = decodeURIComponent(cookies.substring(position + this.confirmDisplayed.length,end));
  67.         return conDisp;
  68.     }
  69. };
  70.  
  71. Timeout.prototype.getExpiryTime = function(){
  72.     var cookies = document.cookie;
  73.     var position = cookies.indexOf(this.cookieString);
  74.     if(position != -1){
  75.         var end = cookies.indexOf(";",position);
  76.         if(end == -1){end = cookies.length};
  77.         var expTime = decodeURIComponent(cookies.substring(position + this.cookieString.length,end));
  78.         return parseInt(expTime);
  79.     }
  80. };
  81.  
  82. Timeout.prototype.displayConfirm = function(expTime){
  83.     var message = "Your current session will time out in approximately " + alertDuration + " minutes, at ";
  84.     message += this.formatDate(new Date(expTime + (alertDuration * 60 * 1000)));
  85.     message += ".\n\nSelect OK to renew your session and continue using eCEM Tool.  Otherwise select Cancel to logout.";
  86.     return window.confirm(message);
  87. };
  88.  
  89. Timeout.prototype.formatDate = function(expDate){
  90.     var hours = expDate.getHours();
  91.     var minutes = expDate.getMinutes();
  92.     var seconds = expDate.getSeconds();
  93.     var ampmIndicator = "AM";
  94.     if(hours >= 12){
  95.         ampmIndicator = "PM";
  96.     }
  97.     if(hours == 0){
  98.         hours = 12;
  99.     }else if(hours > 12){
  100.         hours = hours - 12;
  101.     }
  102.     if(minutes < 10){
  103.         minutes = "0" + minutes;
  104.     }
  105.     if(seconds < 10){
  106.         seconds = "0" + seconds;
  107.     }
  108.     return hours + ":" + minutes + ":" + seconds + " " + ampmIndicator;
  109. };
  110. /*
  111.  * Make an asynchronous call to renewSession page. 
  112.  * This is a regular JSP that does nothing, but return true
  113.  * if no Exceptions are thrown on the server side. 
  114.  * If request is successful update sessionexpiry cookie to 
  115.  * current time. 
  116.  */
  117. Timeout.prototype.extendSession = function(){
  118.     //Display error if the session has already expired
  119.     var et = this.getExpiryTime() + (alertDuration * 60 * 1000);
  120.     if(new Date().getTime() >= et){
  121.         alert("Your current session cannot be renewed as it expired at " + this.formatDate(new Date(et)));
  122.         this.sessionTimeOut();
  123.  
  124.     }
  125.     var xmlhttp;
  126.     if(window.XMLHttpRequest){
  127.           xmlhttp=new XMLHttpRequest();
  128.           alert("XMLHttpRequest="+xmlhttp);
  129.     }
  130.           else
  131.               {
  132.               xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  133.               alert("ActiveXObject="+xmlhttp);
  134.     }
  135.  
  136.  
  137. //    request.open("GET",this.renewURL,true);
  138.  
  139.     /* 
  140.        Using the above renew URL approach, causes the FACES view getting
  141.        updated with the view of renew page.So after the session extension, 
  142.        the user actions in the current page doesn't really happen.
  143.     */
  144.     //var url=document.URL;
  145.     //alert("newurl="+newurl);
  146.     xmlhttp.open("GET",document.URL,true);
  147.     alert(xmlhttp.open("GET",document.URL,true));
  148.     alert("document.URL="+document.URL);
  149.     xmlhttp.onreadystatechange = function(){
  150.         if(xmlhttp.readyState==4){
  151.             alert("inside readystate=="+xmlhttp.readyState);
  152.             alert("response="+xmlhttp.responseText);
  153.             //The session was renewed if we received a HTTP response
  154.             //status of 200.  We are not interested in the actual response. 
  155.             //reset the instance of Timeout by calling start().
  156.  
  157.             if(xmlhttp.status==200){
  158.                 alert("request.status="+xmlhttp.status);
  159.                 alert("response="+xmlhttp.statusText);
  160.                 Timeout.prototype.start();
  161.             }else{
  162.                 Timeout.prototype.displayRenewError();
  163.             }
  164.         }        
  165.     };
  166.  
  167.      xmlhttp.send();
  168. };
  169.  
  170. Timeout.prototype.logout = function(){
  171.     window.location = this.logoutURL;
  172. };
  173.  
  174. Timeout.prototype.sessionTimeOut = function(){
  175.     window.location = this.sessionTimeOutURL;
  176. };
  177.  
  178. Timeout.prototype.displayRenewError = function(){
  179.     alert("Error renewing current session.\n\nPlease save your work immediately.");
  180. };
Jun 6 '13 #1
0 1559

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ted Bogucki | last post by:
I have an asp application running on both iis5 and iis6. (not .net) The server ruhnning IIS5 has no problem running my application. IIS6 randomly times out WEB users. The session timeout...
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...
5
by: Tim W. | last post by:
Folks. In a B2B Procurement system we've created, we got following Session-Issue: Configuration: We are using IIS 6.0 and added SQL-Based-Sessions in web.config with a timeout of 240 minutes...
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...
20
by: Simon Says | last post by:
Hi, I've a login page in which after authenticating it via the Oracle DB, I will stored the user information into the Session. However, when the Session timeout occurs, all of the user...
3
by: Sems | last post by:
Hi I'm using the Session_End event in the global.asax to detect if a users sessions has ended. Is there any way to tell if the session end is due to it being expired and not abandoned? I'm...
3
by: trullock | last post by:
Hi, I want to test some session timeout code ive written but im getting a few problems. I want to reduce the session timeout to 1min so i dont have to wait around for 20 min to see if my code...
4
by: goscottie | last post by:
I used submodal as my popup window. With some tweaks, it working great in my app. However, I can't find a way to detect session timeout in the popup window. The app is a form based...
5
by: Mugs321 | last post by:
Hi all, I'm having a problem with extending Session Timeouts... hopin someone can help.. This is the line under my <system.web> tag in my web.config: <sessionState mode="InProc" timeout="45"...
7
by: anithaapr05 | last post by:
Hi, I am creating a session when user successfully login to the site and user gets a form to input some data into database. Assume that user entered data into some fileds and let the browser...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.