Session Expiration Warning Popup Plugin - jQuery Idle Hands
A simple yet configurable idle detection jQuery plugin that detects user activities on your webpage and displays a warning dialog popup when session timeout.
Demo
Download

seen from Sweden
seen from Malaysia

seen from United States
seen from China
seen from China

seen from Malaysia
seen from Germany
seen from United States
seen from Pakistan
seen from China
seen from Germany
seen from United States

seen from Brazil
seen from Yemen

seen from T1

seen from Brazil

seen from T1

seen from Uruguay

seen from United States
seen from T1
Session Expiration Warning Popup Plugin - jQuery Idle Hands
A simple yet configurable idle detection jQuery plugin that detects user activities on your webpage and displays a warning dialog popup when session timeout.
Demo
Download
JQuery Session Timeout
Most web applications require a user to login and use sessions to track the user’s activity on the site. For security purposes, it can also be desirable to, after a certain period of time of no activity, to automatically log the user out. There is an easy to use plugin for just this purpose that works nicely with the Twitter Bootstrap framework. The Bootstrap Session Timeout plugin by Orangehill…
View On WordPress
I didn't really want to race Arms Race anyway.
Bài viết mới tại Blog hướng dẫn sử dụng phần mềm,Tutorial, TUT, Software...
New Post has been published on http://tut.thuviensoft.com/giai-phap-session-timeout-trong-asp-net/
Giải pháp Session timeout trong ASP.NET
Session timeout Là khoảng thời gian lớn nhất có thể giữa hai lần user request lên server mà session của user chưa bị hủy. Vấn đề thường gặp là Session hay bị mất khi đang xử lý thông tin trước khi Submit form. Bài viết này xin giới thiệu một giải pháp cho vấn đề session timeout trong asp.net
1. Session timeout là gì?
Là khoảng thời gian lớn nhất có thể giữa hai lần user request lên server mà session của user chưa bị hủy. Nói một cách đơn giản hơn, giả sử giá trị timeout này là 30′, thì cứ trong 30′, nếu user không gửi một request nào lên server thì session của user đó sẽ không còn hiệu lực.
Trong ASP.NET, session timeout mặc định là 20′. Có nhiều cách để thay đổi giá trị này, đơn giản nhất là thêm một dòng trong web.config
<sessionState timeout="30"></sessionState>
2. Đặt timeout bao nhiêu là hợp lý?
Giá trị mặc định của nó là 20′, tuy nhiên trong một số trường hợp bạn muốn session tồn tại lâu hơn. Ví dụ một ứng dụng web cho phép người dùng soạn thảo nội dung trực tiếp trên trình duyệt. Bạn không muốn session kết thúc trước khi người dùng soạn thảo xong văn bản, vì thế bạn thiết lập timeout bằng một số rất lớn. Điều này không thực sự ổn vì nó sẽ tốn rất nhiều bộ nhớ của server dành cho session của những người dùng không còn trên website của bạn.
3. Heart beat pattern
Có một giải pháp cho vấn đề này: Thiết lập một giá trị session timeout nhỏ. Đồng thời, phía client sẽ “âm thầm” gửi các request nhỏ, thường xuyên đến server để báo cho server biết nó vẫn còn “sống”. Do đó bạn sẽ không bị tốn bộ nhớ một cách vô ích cho session của những người dùng không còn trên trang. Phương pháp này được biết dưới cái tên Heartbeat design pattern. Tôi thực hiện điều này trong ASP.NET một cách đơn giản như sau: + Thiết lập một giá trị nhỏ cho session timeout (giả sử là 5′)
<sessionState timeout="5"></sessionState>
+ Tạo trang KeepAlive.ashx để nhận request thường xuyên từ client. Trang này không cần làm gì cũng được. + Thêm đoạn code javascript sau vào trang bạn muốn thực hiện. Tốt nhất là đặt chúng trong các trang master page
function heartBeat() $.get("KeepAlive.ashx?", function (data) ); $(function () setInterval("heartBeat()", 1000 * 30); // 30s gửi request một lần );
Tham khảo từ tek.eten.vn
Handling Session timeout during AJAX Call (JavaScript)
Problem Statement : Web 2.0 application development is becoming trend for Enterprise Applications as well. Recently during the course of development, I came across a situation where if client side code (JavaScript for my case) makes an AJAX call and at this moment if timeout happens at the server side then how will you determine its session timeout case at the client side? Observation: In general we expect a plain text response ( usually HTML text ), JSON Response or XML Response. And specifically when you are working on container managed authentication in Application Server or WebSphere Portal Server like product, it will automatically return you the error page as text, having session timeout error information, irrespective of what you were expecting as a response (JSON, XML or HTML). Solution Approach : Initially my team thought of parsing the content sent back from the server but it is not best thing to do so I ignored it. Then we thought of checking cookies but challenge here was decryption of session cookie [ LTPA token in case of WebSphere], for decryption you have to bring encryption key on the client side which you would never want to do. During the discussion with one of the WebSphere Product Team's Architect, I came to know about HTTP Header named 'Content-Location'. As per the definition, this header contains the location/URI of the resource, from where it is being served and only in cases when resource is served from the location different then the one requested. For session timeout scenario, session validation is done before container hits your direct end-point and in case session timeout has occurred it will not actually hit the endpoint requested, instead error page would be served from different source. You can pretty much take advantage of this for validating session timeout. Once you get the response, check for the header Content-Location and if it is not null and not exactly same as requested end point from your AJAX Call function then you can pretty much assume that session timeout has occurred. Now you can implement your specific behavior upon check like for my case I simply re-loaded the page so that Portal Container automatically takes you to the Authentication Page. Totally up to your requirement/need-- Following is the code snippet I used. It is written in Dojo : //resourceURL : URL Originally used to make AJAX call. var contentURL = ioargs.xhr.getResponseHeader("Content-Location"); if(contentURL !=null && contentURL!= resourceURL ){ console.log("Session timeout sceanrio..."); location.reload(); } I am sure there are ways almost in every client side programming language for reading HTTP Header and source url, you can always preserve as you need it before you make AJAX call. HTH--