set('provider', $_GET['provider']); } /** * When provider exists in the storage, try to authenticate user and clear storage. * * When invoked, `authenticate()` will redirect users to provider login page where they * will be asked to grant access to your application. If they do, provider will redirect * the users back to Authorization callback URL (i.e., this script). */ if ($provider = $storage->get('provider')) { $hybridauth->authenticate($provider); $storage->set('provider', null); } /** * This will erase the current user authentication data from session, and any further * attempt to communicate with provider. */ if (isset($_GET['logout'])) { $adapter = $hybridauth->getAdapter($_GET['logout']); $adapter->disconnect(); } /** * Redirects user to home page (i.e., index.php in our case) */ HttpClient\Util::redirect('https://path/to/hybridauth/examples/example_06'); } catch (Exception $e) { echo $e->getMessage(); }