PHP中的会话问题 [英] problems with session in PHP
问题描述
我坚持使用一段代码好几个小时但仍然找不到错误。
我在一个页面中设置一个会话变量并且正在做它在另一页回显,但第二页没有任何输出。
page1.php
session_start();
$ _SESSION ['id'] = 1;
echo $ _SESSION ['id'];
header(Location:page2.php);
?>
page1的输出.php
1
page2.php
session_start();
echo$ _SESSION ['id'];
?>
page2.php的输出
没有输出。
为什么会发生这种情况,怎么做才能使page2.php中的输出为1?
_SESSION ['id'] = 1;
echo
_SESSION ['id '];
header(Location:page2.php);
?>
< u> page1.php的输出
1
page2.php
session_start();
echo
_SESSION ['id'];
?>
page2.php的输出
没有输出。
为什么会发生这种情况,怎么做才能使page2.php中的输出为1?
Im stuck with a piece of code for many hours but still couldn't find a error.
I'm setting a session variable in one page and doing it echo in another page but there isn't any output in the second page.
page1.php
session_start();
$_SESSION['id'] = 1;
echo $_SESSION['id'];
header("Location: page2.php");
?>
output of page1.php
1
page2.php
session_start();
echo " $_SESSION['id']" ;
?>
output of page2.php
No output.
Why this happens and what to do get the output in page2.php as 1 ??
_SESSION['id'] = 1;
echo
_SESSION['id'];
header("Location: page2.php");
?>
output of page1.php
1
page2.php
session_start();
echo "
_SESSION['id']" ;
?>
output of page2.php
No output.
Why this happens and what to do get the output in page2.php as 1 ??
这篇关于PHP中的会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!