会话未显示,但肯定存在,如下一页所示
Sessions not showing but are definitely there as shown from next page
莫名其妙!
我有一个应该存储一些会话的页面,但是当我尝试打印它们时,什么也没有显示。
那里一定有会话,因为第一页有一个 link 带我到第二页,在第二页我可以成功显示会话!
<?
session_start();
include "frontend/header.php";
?>
</head>
<body>
<div id="header">
<? include "frontend/menu.php";?>
<div class="clear"></div>
</div>
<div id="green_bg" style="display:block">
<?
echo "1";
echo "<pre>";print_r($_SESSION); echo"</pre>";
?>
<div class="main thank-you">
<a class="thank_you">Thank You</a>
<p>Your phone number will be refilled in a moment. <br/>
Please check your emails for confirmation.
</p>
<div class="signUp4MonthlyRefills" style="background-color: #f7931e; padding: 20px;">
<h3>Do you want to save time and effort?</h3>
<br/>
Then leave the refills to us!!
<br/>
<br/><i>Introducing</i>... Auto Monthly Refills!!
<p>Sign up for automatic monthly refills and you'll never have to worry about your phone running out of credit!
<h1 align="center"><a href="auto-monthly-refills-form.php" style="font-size: 30px">Click Here To Sign Up.</a></h1></p>
</div>
<br />
</div>
</div>
<? include "frontend/footer.php";?>
当代码调用会话时,页面只显示“1”,然后显示一个空数组(即打印 "array()")。
然后当点击 link 到 "auto-monthly-refills-form.php" 时,它会显示所有会话!
"auto-monthly-refills-form.php"
文件如下所示:
<?
session_start();
echo "<pre>";print_r($_SESSION); die();
现在显示会话(大量数据)!!
如果有人有任何想法可能是什么问题...
更新:
即使删除了两个页面上的 session_start() ,它仍然可以正常工作!怎么会这样?
好的...整理出来...请阅读...
尽管这是一个新页面,但代码有点脱离其他文件层...
我不认为这应该是个问题...
(我原以为每个页面都需要它自己的 session_start()
但出于某种原因它们不需要并且它们显然都基于一页......解释起来有点复杂 - 足以说明我正在尝试整理其他人的代码:-P)
无论如何,我检查了与此文件相关的所有文件,删除了除主要文件之外的所有 session_start()
。现在它工作正常。
数据显示完美!
问题:
有人对此有解释吗?
为什么 session_starts()
太多会导致问题?
莫名其妙!
我有一个应该存储一些会话的页面,但是当我尝试打印它们时,什么也没有显示。
那里一定有会话,因为第一页有一个 link 带我到第二页,在第二页我可以成功显示会话!
<?
session_start();
include "frontend/header.php";
?>
</head>
<body>
<div id="header">
<? include "frontend/menu.php";?>
<div class="clear"></div>
</div>
<div id="green_bg" style="display:block">
<?
echo "1";
echo "<pre>";print_r($_SESSION); echo"</pre>";
?>
<div class="main thank-you">
<a class="thank_you">Thank You</a>
<p>Your phone number will be refilled in a moment. <br/>
Please check your emails for confirmation.
</p>
<div class="signUp4MonthlyRefills" style="background-color: #f7931e; padding: 20px;">
<h3>Do you want to save time and effort?</h3>
<br/>
Then leave the refills to us!!
<br/>
<br/><i>Introducing</i>... Auto Monthly Refills!!
<p>Sign up for automatic monthly refills and you'll never have to worry about your phone running out of credit!
<h1 align="center"><a href="auto-monthly-refills-form.php" style="font-size: 30px">Click Here To Sign Up.</a></h1></p>
</div>
<br />
</div>
</div>
<? include "frontend/footer.php";?>
当代码调用会话时,页面只显示“1”,然后显示一个空数组(即打印 "array()")。
然后当点击 link 到 "auto-monthly-refills-form.php" 时,它会显示所有会话!
"auto-monthly-refills-form.php"
文件如下所示:
<?
session_start();
echo "<pre>";print_r($_SESSION); die();
现在显示会话(大量数据)!!
如果有人有任何想法可能是什么问题...
更新:
即使删除了两个页面上的 session_start() ,它仍然可以正常工作!怎么会这样?
好的...整理出来...请阅读...
尽管这是一个新页面,但代码有点脱离其他文件层...
我不认为这应该是个问题...
(我原以为每个页面都需要它自己的 session_start()
但出于某种原因它们不需要并且它们显然都基于一页......解释起来有点复杂 - 足以说明我正在尝试整理其他人的代码:-P)
无论如何,我检查了与此文件相关的所有文件,删除了除主要文件之外的所有 session_start()
。现在它工作正常。
数据显示完美!
问题:
有人对此有解释吗?
为什么 session_starts()
太多会导致问题?