setcookie未设置cookie,但有0个错误(SSO)

时间:2019-06-16 05:14:44

标签: php cookies setcookie

我让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

0 个答案:

没有答案