簡體   English   中英

檢索注銷時間而不注銷

[英]retrieve logout time without logout

用戶關閉瀏覽器但未注銷時,如何查看注銷時間?

因此,我實現了從此處獲取的HttpSessionBindingListener ,並Listener in web.xml添加了Listener in web.xml但是關閉瀏覽器后未將注銷時間插入數據庫。 有什么建議請問我哪里錯了?

logout.jsp

 <%
    ObjectWillBeInSession owi = new ObjectWillBeInSession();
    owi.setProperty1("I am a value for Property1");
    owi.setProperty2("I am a value for Property2");
    //this will call HttpSessionBindingListener's 
    //valueBound method for the object
    session.setAttribute("owi", owi);

    //this will call HttpSessionBindingListener's 
    //valueUnbound method for the object
    session.removeAttribute("owi");   
        //INSERT INTO DB.......BUT IT IS NOT WORKING
 %>

關閉瀏覽器不會觸發對服務器的任何請求,因此無法知道用戶已關閉其瀏覽器。 您可以使用偵聽器來使會話超時,然后在發生這種情況時存儲當前時間。 不過,會話通常會在客戶端發出最后一個請求后的幾個小時后過期。

您可以使用JavaScript的window.onbeforeunload將AJAX請求發送到servlet,以記錄用戶關閉瀏覽器並在會話對象中執行所需操作的時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM