Parsing username value in Authorization request header.
session_start();//старт сессии
// todo логика проверки смены пользователя
$username = null;
$reqHeaders = apache_request_headers();
if(isset($reqHeaders['Authorization'])){
$matches = array();
preg_match('/username="(\w+)"/', $reqHeaders['Authorization'], $matches);
if(isset($matches[1])){
$username = $matches[1];
}
if ( $_SESSION['username'] != $username )
$_SESSION['userIsChange'] = "true";
else
$_SESSION['userIsChange'] = "false";
$_SESSION['username'] = $username;
}