private function storeAccessTokenInSession(\OAuth2\ResponseInterface $response) { $location = $response->getHttpHeader('Location'); $parsed = parse_url($location); if (isset($parsed['fragment'])) { $fragment = $parsed['fragment']; } else { $fragment = $parsed['query']; } parse_str($fragment, $attributes); if (isset($attributes['access_token'])) { //$_SESSION['oauth2_access_token'] = $attributes['access_token']; Application::getInstance()->getRouter()->getRequest()->getSession()->set('oauth2_access_token', $attributes['access_token']); } }