0

我正在使用以下代码。会话在同一页面上工作;在下一页上,它没有显示会话变量值。请让我知道我做错了什么?

<?php 
    session_start();
    $_SESSION['emailaddress']=$emailAddress;
    header("Location: $success "); /* Redirect browser */
    exit;
?>
4

2 回答 2

0

use session_start() in the page that you are redirecting to, as well ($success), before accessing the session values there

So that the "success.php" page looks something like:

<?
session_start();
print_r($_SESSION); 
?>
于 2012-08-17T22:53:42.783 回答
0
<?php
if(some_condition is true)
{
session_regenerate_id();
session_start();
$_SESSION['emailaddress']=$emailAddress;
header("location: member-index.php");
exit();
}

在安全页面上:

<?php
//Start session
session_start();
//Check whether the session variable is present or not
       if(!$_SESSION['emailAddress']) 
        {
        header("location: access-denied.php");
        exit();
    }
?>

<p>This is secured page with session: <b><?php echo $_SESSION['emailAddress']; ?></b>
于 2012-08-17T23:02:48.123 回答