I am currently implementing and at the same time learning the use of OpenId. Specifically using lightopenid. It is working but I would like users that are needing to login to be redirected automatically to the login page when accessing the url www.example.com/login. The example below has the user click on a button and then redirects the user to the login page. How can I redirect the user automatically with url www.example.com/login to the open ID login page?
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID('localhost');
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://www.google.com/accounts/o8/id';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}