Hey, i’m using the examples provided and simply trying to go back to the same login page after the user is logged in, so if auth0
has got a user then we don’t hit the login method, I have more code below to run after they have logged in.
Issue i’m having is that after I login, then logout, the user still appears to be logged in, so my steps:
- Login through
login.php
. - Directed back to
login.php
and the users details are displayed. - Logout in
logout.php
, get directed to/
. - Go to
login.php
and the users details are displayed, but I should be getting sent to the login form.
login.php
/** @noinspection PhpUnhandledExceptionInspection*/
$auth0 = new Auth0([
'domain' => AUTH0_DOMAIN,
'client_id' => AUTH0_CLIENT_ID,
'client_secret' => AUTH0_CLIENT_SECRET,
'redirect_uri' => DMS_URL.'/login.php'
]);
if (!$user = $auth0->getUser()) {
$auth0->login();
}
dd($user);
logout.php
/** @noinspection PhpUnhandledExceptionInspection*/
$auth0 = new Auth0([
'domain' => AUTH0_DOMAIN,
'client_id' => AUTH0_CLIENT_ID,
'client_secret' => AUTH0_CLIENT_SECRET,
'redirect_uri' => DMS_URL.'/'
]);
$auth0->logout();
$return_to = DMS_URL.'/';
$logout_url = sprintf('http://%s/v2/logout?client_id=%s&returnTo=%s', AUTH0_DOMAIN, AUTH0_CLIENT_ID, $return_to);
header('Location: ' . $logout_url);
Edit:
So, after some investigation is appears that even after hitting the logout
page, the $_SESSION('auth0__user')
key isn’t being cleared. Due to the documentation using getUser()
to distinguish if a user is logged in, it doesn’t make sense for Auth0 to not clear this by default?