我让URL栏中的setcookie和参数为我做SSO。登录时,它不会设置cookie。这是示例和代码。
<?php
$site = $_GET["source"];
$allowed_sites = array("site1.com", "site2.com", "site3.com");
$_SESSION["loggedin"] = true;
$_SESSION["username"] = $username;
$encodeduser = base64_encode($_SESSION["username"]);
if(in_array($site, $allowed_sites)) {
setcookie('username', $encodeduser, time() + 3600, '/', $site);
} else {
setcookie('username', $encodeduser, time() + 3600, '/', 'site1.com');
}
?>
网站网址示例
https://login.parappawithfries.com/?source=site.parappawithfries.com