userAccess.php에 이것을 작성하십시오
<?php
session_start();
echo 'User is: ' . $_SESSION['admin']['fname'] . ' ' . $_SESSION['admin']['lname'];
?>
문제
나는 현재 구현 중입니다 lightopenid. 부분적으로 작동하지만 자격 증명을 유지하면서 사용자를 리디렉션하는 데 어려움이 있습니다. 아래의 예에는 Google을 통해 사용자 로그인 한 다음 사용자 액세스 페이지로 리디렉션하여 이름이 표시됩니다. userAccess.php에는 아무것도 표시되지 않습니다. OpenID의 자격 증명으로 사용자를 올바르게 리디렉션하려면 어떻게해야합니까?
login.php
<?php
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
session_start();
require 'openid.php';
try {
$openid = new LightOpenID('http://mydomain.com'); // akshat - declared an object of class lightopenid.. this is listed in openid.php
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://www.google.com/accounts/o8/site-xrds?hd=mydomain.com'; //this can be changed as you know...
$openid->required = array('namePerson/friendly', 'contact/email' , 'contact/country/home', 'namePerson/first', 'pref/language', 'namePerson/last'); // akshat - line added by me from after reading from the net....
header('Location: ' . $openid->authUrl());
}
?>
<script type="text/javascript">
//change to jquery so it is compatible with cross browsers
window.onload=function(){
document.getElementById("lform").submit();
}
</script>
<form name="form" id="lform" action="?login" method="post"> </form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication for Your Domain !';
} else { // FETCH USER INFO HERE
$fname = $openid->ret_fname(); // fetching user first name...
$lname = $openid->ret_lname(); // fetching user last name...
$email = $openid->ret_email(); // fetching user email...
$lang = $openid->ret_lang(); // fetching user language...
session_start();
// use it as required. I set them in session !
$_SESSION['admin']['emailID'] = $email; //put email id in session.
$_SESSION['admin']['fname'] = $fname; //put first name also in session.
$_SESSION['admin']['lname'] = $lname; //put last name also in session.
header("Location: www.example.com/useraccess.php"); // Go back to the calling application !
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
?>
userAccess.php
<?php
session_start();
echo 'User is: ' . $fname . ' ' . $lname;
?>
해결책
userAccess.php에 이것을 작성하십시오
<?php
session_start();
echo 'User is: ' . $_SESSION['admin']['fname'] . ' ' . $_SESSION['admin']['lname'];
?>