示例#1
0
function util_doDigitalFieldNotebooksIdSecurityCheck()
{
    if (!isset($_COOKIE["digitalfieldnotebooks_id"]) || !$_COOKIE["digitalfieldnotebooks_id"]) {
        if (isset($_SESSION['digitalfieldnotebooks_id']) && $_SESSION['digitalfieldnotebooks_id']) {
            // the session has an digitalfieldnotebooks id, but there was no cookie set for it - highly suspicious
            // TODO: log and/or message?
            util_redirectToAppHomeWithPrejudice();
        }
        $digitalfieldnotebooks_id = util_genRandomIdString(300);
        setcookie("digitalfieldnotebooks_id", $digitalfieldnotebooks_id);
        $_SESSION['digitalfieldnotebooks_id'] = $digitalfieldnotebooks_id;
    } elseif (!isset($_SESSION['digitalfieldnotebooks_id']) || $_COOKIE["digitalfieldnotebooks_id"] != $_SESSION['digitalfieldnotebooks_id']) {
        // there was an appropriately named cookie, but the value doesn't match the one associated with this session
        // TODO: log and/or message?
        util_redirectToAppHomeWithPrejudice();
    }
}
 function testGenRandomIdString()
 {
     $randomId = util_genRandomIdString(24);
     $this->assertEqual(24, strlen($randomId));
 }