public function authorize()
{
AmyLogger::logn('Authorizing session, cookie token value:', $_COOKIE['amy_token']);
if (!isset($_COOKIE['amy_token']) || '32' != strlen($_COOKIE['amy_token'])) {
AmyLogger::logn('Invalid or non-existent session token.');
throw new Exception('Invalid or non-existent session token.');
}
$session_path = $this->session_storage_path . $_COOKIE['amy_token'];
if (!@file_exists($session_path)) {
AmyLogger::logn("Unable to authorize session: `session file not found at {$session_path}'.");
throw new Exception("Unable to authorize session: `session file not found'.");
}
$this->authInfo = @unserialize(@file_get_contents($session_path));
if (!is_array($this->authInfo)) {
AmyLogger::logn("Unable to authorize session: `session file corrupted or could not been read at {$session_path}'.");
throw new Exception("Unable to authorize session: `session file unreadable or corupted'.");
}
AmyLogger::logn("Session authorized.", $this->authInfo);
return $this;
}