本文整理匯總了PHP中SessionManager::isAuthorized方法的典型用法代碼示例。如果您正苦於以下問題:PHP SessionManager::isAuthorized方法的具體用法?PHP SessionManager::isAuthorized怎麽用?PHP SessionManager::isAuthorized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SessionManager
的用法示例。
在下文中一共展示了SessionManager::isAuthorized方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
function __construct()
{
if (SessionManager::isAuthorized()) {
header('Location:/main');
die;
}
}
示例2: SessionManager
/**
* Created by PhpStorm.
* User: Dushyant
* Date: 2015-07-25
* Time: 11:47 PM
*/
require_once '../../Local/Classes/config.inc';
require_once '../../Local/Classes/class.SessionManager.inc';
session_start();
//Don't allow user to access this page with out logging in and if user role != "Admin"
//Check if user is login or redirect to log in page.
if (isset($_SESSION['loginUserId'])) {
$userSession = new SessionManager();
//if user is log in check user is authorized to use admin pages.
//if not authorized redirect to login page.
if (!$userSession->isAuthorized('Admin', $_SESSION['loginUserRole'])) {
header('Location: ../login.php');
}
} else {
header('Location: ../login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">