/** * Function will match the given key with the saved session key * * @param string $key The key to match (sha1 hash) * * @return bool Returns true if keys match - false if session key has not been set yet or keys don't match */ function token_validate($token) { if (sessionexists('token')) { if (session('token') == $token) { return true; } } return false; }
ini_set('session.gc_maxlifetime', SESSION_TIMEOUT); // Set the session timeout ini_set('session.hash_function', 'sha512'); // Increase session security by using a longer hash (SHA-512 vs MD5) session_start(); // Start this session } if (METHOD != 'CLI') { if (cookieexists('session')) { // Check if user already has a session define('FIRSTVISIT', false); } else { define('FIRSTVISIT', true); } // Otherwise this is a new visitor if (sessionexists('loggedin')) { define('LOGGEDIN', true); Lightwork::Log('User is logged in.', Lightwork::LOG_DEBUG); } else { define('LOGGEDIN', false); Lightwork::Log('User is not logged in.', Lightwork::LOG_DEBUG); } } if (!MULTILANGUAGE) { Translation::Initialize(LANGUAGE); } else { Translation::Initialize(Translation::IdentifyLanguage()); } // Multi language needed, try to identify the necessary language for this request Lightwork::Initialize(); // Basic initialization is done. Lets get the Framework started...