当管理员用户的帐户超时时,我该如何提醒他们 [英] How do I alert admin users when their account has timed out

查看:117
本文介绍了当管理员用户的帐户超时时,我该如何提醒他们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程的网站是一本高中报纸.最近,管理页面出现了一个趋势问题.当用户创建文章时,由于设置的时间限制,他们已注销.我想对警报进行编程,以告知用户他们已注销,以便他们可以复制其文章并将其粘贴回原处.这是我们的超时代码:

The website I program for is a high school newspaper. Lately, the admin page has been having a trending issue. When by the time users have created an article, they have been logged out due to a set time limit. I want to program in an alert to tell users they have been logged out so that they can copy their article and paste it back in place. This is our timeout code:

    // Kill Session if session end exists.
    if ($_GET['endsession']) {
        unset($_SESSION['name']);
        unset($_SESSION['access']);
        unset($_COOKIE['username']);
        setcookie("username","",time() - 3600);
        session_destroy();
        header("Location: http://" . $_SERVER['HTTP_HOST'] . "/admin.php");
    }

我尝试将JavaScript警报放置在[session_destroy(); ]以及[[setcookie("username",",time()-3600); ],但是什么也没发生.我也尝试将其放置在[session_destroy(); ],但该页面甚至无法使任何人超时.

I have tried placing a javascript alert under the [ session_destroy(); ] and above the [ setcookie("username","",time() - 3600); ], but that resulted in nothing happening. I also tried placing it above the [ session_destroy(); ], but that made the page not even time anyone out.

当函数[session_destroy(); ]运行?

How do I get a simple Javascript alert to run when the function [ session_destroy(); ] runs?

推荐答案

您如何检查-在取消会话设置之前-如果还剩下五分钟?

How about you check - before unsetting the session - if there are, let's say, five minutes left?

if($_GET['endsession'] < time() + 5*60) {
    //alert the user
}

if($_GET['endsession']) {
    //your code to unset the session
}

假定$_GET['endsession']包含一个时间戳.如果不是这种情况,您也可以对其进行任何转换,但我认为总体思路很明确.

Assuming $_GET['endsession'] contains a timestamp. If this is not the case you may as well transform it or whatsoever, but I think the general idea is clear.

这篇关于当管理员用户的帐户超时时,我该如何提醒他们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆