Php http和https之间的会话cookie,域和子域分开

Php http和https之间的会话cookie,域和子域分开,php,session,cookies,Php,Session,Cookies,我将网站的面板部分更改为安全SSL位置:“”,并将其配置为在DirectAdmin上的其他用户处创建的单独域。这样做是出于安全原因,并且将来可以将面板移动到完全不同的服务器上 网站http正常网站用户1在DA上。 DA上的子域https安全面板user2。 出现的问题是:当某人已从http或https登录并转到secure login.php https,登录后返回http,您不会看到您已登录及其附带的选项,但会再次看到登录表单。我想用会话cookie显示登录选项,如概览和我在http上的信息

我将网站的面板部分更改为安全SSL位置:“”,并将其配置为在DirectAdmin上的其他用户处创建的单独域。这样做是出于安全原因,并且将来可以将面板移动到完全不同的服务器上

网站http正常网站用户1在DA上。 DA上的子域https安全面板user2。 出现的问题是:当某人已从http或https登录并转到secure login.php https,登录后返回http,您不会看到您已登录及其附带的选项,但会再次看到登录表单。我想用会话cookie显示登录选项,如概览和我在http上的信息

我试过很多饼干之类的东西,但都做不好。如果我在浏览器中检查cookies,我会看到panel.website.com和www.website.com都有不同的会话id。这是我正在使用的最新代码

Login.php HTTPS页面

<?php
// regenerate session id to make session fixation more difficult
session_regenerate_id(true);

// generate random code for the authentication cookie and store it in the session
$authCode = md5(uniqid(mt_rand(), true));
$_SESSION['authentication'] = $authCode;

// create authentication cookie, and restrict it to HTTPS pages
setcookie('authentication', $authCode, 0, '/', '', true, true);
?>

<form method="post" action="https://panel.website.com/login">
<table>
<tr>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><input type="password" name="password"  /></td>
</tr>
<tr>
<td><input type="submit" name="login" value="login" /></td>
</tr>
</table>
</form>
带有登录表单和链接/选项的Index.php HTTP

<?php
// check that the authentication cookie exists, and that
// it contains the same code which is stored in the session.
$pageIsSecure = (!empty($_COOKIE['authentication']))
&& ($_COOKIE['authentication'] === $_SESSION['authentication']);

if (!$pageIsSecure)
{
不显示页面,重定向到登录表单

<form method="post" action="https://panel.website.com/login">
<table>
<tr>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td><input type="password" name="password"  /></td>
</tr>
<tr>
<td><input type="submit" name="login" value="login" /></td>
</tr>
</table>
</form>
在登录http后显示其他选项

<?php }else{ ?> 

<li><a href=" https://panel.website.com/overview">Overview</a></li>
<li><a href=" https://panel.website.com/my-information">My Information</a></li>

<?php } ?>

类似的问题:,,是的,我知道还有更多的话题。已经查看了许多并尝试了这些修复,但无法正确执行。