0

HTMLページのプログレスバーにセッションタイムアウトカウントダウンを表示する適切なコードを取得しているときに、いくつかの問題に直面しています。

誰かがこれを行うのを手伝ってくれますか?

ありがとう

4

1 に答える 1

0

インターネットで検索したところ、これを行う方法の例が1つ見つかりました。以下に簡単な例を示し$inactiveます。変数はセッションの有効期限 (600秒など) です。

function start_onload(){
    var expire_time = new Date().getTime() + 1000*<?php echo $inactive; ?>;
    countdown_session_timeout();
    function countdown_session_timeout() {
        var current_time = new Date().getTime();
        var remaining = Math.floor((expire_time - current_time)/1000);
        var timeout_message = document.getElementById('timeout_message');
        if (remaining>0) {
            timeout_message.innerHTML = 'Session will expire in '+ Math.floor(remaining/60) + ' min. ' + (remaining%60) + ' sec.';
            setTimeout(countdown_session_timeout, 1000);
        } else {
            timeout_message.innerHTML = 'Session expired.';
        }
}

}

Php スクリプトはこちら: http://pastebin.com/Dik0hyYd (これらのセッションは単なる例です。)

于 2012-07-17T23:02:13.657 に答える