我将此代码包含在我的 php 网页顶部
<?php
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
session_start();
?>
这是php网页
a.php
<h1>Page AAAA</h1>
<a href="b.php?t=<? echo time(); ?>">go to page B</a>
<?php
echo "<h2>CURRENT SESSION = ", $_SESSION['test'], "</h2>";
$_SESSION['test'] = 'a';
echo "<h2>AFTER CHANGE SESSION = ", $_SESSION['test'], "</h2>";
?>
b.php
<h1>Page BBBB</h1>
<a href="a.php?t=<? echo time(); ?>">go to page A</a>
<?php
echo "<h2>CURRENT SESSION = ", $_SESSION['test'], "</h2>";
$_SESSION['test'] = 'b';
echo "<h2>AFTER CHANGE SESSION = ", $_SESSION['test'], "</h2>";
?>
但它不起作用。CURRENT SESSION
即使我在a.php和b.php之间切换也没有价值
更新我将此代码包含在a.php
echo "<h1>SESSION ID = ", session_id() , "</h1>";
结果中
SESSION ID = fhhiilg08rl2ajtplqc9dbud43