我正在尝试8小时来修复它,这篇文章对我没有帮助:Allow php sessions to carry over to subdomains
我在新的sub.domains.com上丢失了我的ID会话 以下是代码:来自sub.domains.com
if($postac['zalogowany'] == 0){ $postac = ""; $_SESSION['postac'] = 0; }
来自domena.com的login.php
if($doVariable == 'play' && $_POST['postac'] > 0) {
if($_GET['serv'] == 'cos')
$server = 'baza';
$_SESSION['postac'] = $_POST['postac'];
$zalogowany = $pdo->prepare("UPDATE postac set zalogowany = 1 where id=:postac");
$zalogowany->bindValue(':postac', $_SESSION['postac'], PDO::PARAM_STR);
$zalogowany->execute();
if($_GET['serv'] == 'play');
header("Location: http://sub.domains.com");
}
答案 0 :(得分:1)
您可以在php.ini中更改session.cookie_domain,以允许在子域中读取cookie。您也可以在运行时使用session_set_cookie_params。
session.cookie_domain = ".domains.com"