相关疑难解决方法(0)

PHP会话变量未保留

我无法在设置它们的页面上使用会话变量,它们就像非会话变量一样.我在其他六个类似的论坛上发现了一个类似的问题,但在其他案例中的答案总是不适用.

这是我的文件:

sess1.php

<?php
session_start();

session_register("userid");
session_register("textvar");

$_SESSION['userid'] = 10333 ;
$_SESSION['textvar'] = TextVariable ;

echo "<p>User ID is: " . $_SESSION['userid'] . "</p>" ;
echo "<p>Another variable is: " . $_SESSION['textvar'] . "</p>" ;
?>
<p>Go to the <a href="sess2.php">next page</a>.</p>
Run Code Online (Sandbox Code Playgroud)

并且, sess2.php

<?php
session_start();

echo "<p>The userid session variable is: " . $_SESSION['userid'] . "</p>";
echo "<p>The other session variable is: " . $_SESSION['newvar']. "</p> ";
?>
Run Code Online (Sandbox Code Playgroud)

每种情况下的浏览器输出是:

sess1.php

用户ID是:10333

另一个变量是:TextVariable

转到[下一页].

并且, sess2.php

userid会话变量是:

另一个会话变量是:

转到[最后一页].

有些事情不是: …

php session session-variables

7
推荐指数
2
解决办法
9657
查看次数

标签 统计

php ×1

session ×1

session-variables ×1