Close session and start a new one

前端 未结 4 1520
小蘑菇
小蘑菇 2020-12-17 17:09

I\'m testing the implementation of a security check in my PHP sessions. I can successfuly detect whether the session was started from another IP address and I can successful

4条回答
  •  攒了一身酷
    2020-12-17 17:27

    when a new user connects to your server, the script should only be able to access that user's session variables. you will want to store other info in a hashed session variable to verify that the session is not being jacked. if it is being jacked, no reason to start a new session, maybe just exit the script with a warning.

    here is the function a lot of people use for fingerprinting a session:

    function fingerprint() {
        $fingerprint = $server_secure_word;
        $fingerprint .= $_SERVER['HTTP_USER_AGENT'];
        $blocks = explode('.', $_SERVER['REMOTE_ADDR']);
        for ($i=0; $i<$ip_blocks; $i++) {
            $fingerprint .= $blocks[$i] . '.';
        }
        return md5($fingerprint);
    }
    

提交回复
热议问题