配置文件毁了我的网站

时间:2014-11-26 14:02:39

标签: php xss config

我是一名网站开发人员,现在已经在网站上工作了3个星期,我遇到了同样的问题。当我登录并被重定向到index.php时,会话被完全删除并重新启动。因此,所有登录变量和您登录的证据都没有转到其他站点。

当我查看我的代码时,我写了一个预先的反黑客配置文件,那个配置文件太好了。它停止了很好的黑客攻击,所以它认为我是一个黑客(我不知道为什么)。我已经搜索了这么多个小时来找到为什么它认为我是黑客但没有结果。

问:有人可以解释为什么在重定向到主页后进行新会话,这是我的代码:

ini_set('session.cookie_secure', true);
ini_set('session.cookie_httponly', true);   //Cookies are a very good hacking method*/
session_start();

$_SESSION['time-bomb'] = time();    //You can't be logged in forever

if(!isset($_SESSION['regid'])){
    session_regenerate_id();    //Now the client can't change name
    $_SESSION['regid'] = true;
}

if (isset($_SESSION['last_ipofyours'])) {

    if ($_SESSION['last_ipofyours'] !== $_SERVER['REMOTE_ADDR']) {
    // The first one is always the right one
        session_unset();
        session_destroy();
        die("This IP will probebly be checked, we have seen some hacking activity on this IP.");
    }
} else {
    $_SESSION['last_ipofyours'] = $_SERVER['REMOTE_ADDR'];
}

if($_SESSION['time-bomb'] > time() + 300) { //You can't be logged in forever
    session_unset();
    session_destroy();
    die("Session expired, please relogin. Or you are hacking then this will be loged and prevented by baning your IP!"); 
}

1 个答案:

答案 0 :(得分:2)

安全cookie将在https页面上提供。

我想你使用http://www.example.com/index.php
试试https://www.example.com/index.php

相关问题