0
问题:会话变量不会在重定向后继续。php会话变量不会继续重定向
facebook.php(会话变量创建的,并存储)
按钮引导到available.php - > searching.php
我使用报头重定向。所以$ _SESSION [ 'seshfbId']上available.php回声但不searching.php
代码
facebook.php
<?php
session_start(); // start up your PHP session!
header('Location: http://www.redacted.co/chat.php') ;
function createSeshVariables($name, $email, $college, $photo, $id)
{
// set the value of the session variable 'name'
$_SESSION['seshName'] = $name;
// set the value of the session variable 'email'
$_SESSION['seshEmail'] = $email;
// set the value of the session variable 'education'
$_SESSION['seshEducation'] = $college;
// set the value of the session variable 'photolink'
$_SESSION['seshPhotolink'] = $photo;
// set the value of the session variable 'photolink'
$_SESSION['seshfbId'] = $id;
}
createSeshVariables($fbName,$fbEmail,$fbCollege,$photolink,$fbId);
?>
available.php
<?php
session_start(); // start up your PHP session!
header('Location: http://www.redacted.co/assets/php/searching.php');
echo $_SESSION['seshfbId'];
//if i comment out header redirect the echo works here.
changeStatusToAvailable($_SESSION['seshfbId']);
?>
searching.php
<?php
session_start(); // start up your PHP session!
echo $_SESSION['seshfbId'];
?>
编辑:在vardump之后,我在搜索页上找到了seshId和seshToken。但用于创建tac.php的代码。我有一种感觉tac.php代码发生冲突,与会话变量前面
tac.php
$apiObj = new OpenTokSDK(API_Config::API_KEY, API_Config::API_SECRET);
$session = $apiObj->createSession($_SERVER["REMOTE_ADDR"], array(SessionPropertyConstants::P2P_PREFERENCE=> "enabled"));
$seshId = $session->getSessionId();
$_SESSION['seshId'] = $seshId;
$token = $apiObj->generate_token($seshId, RoleConstants::PUBLISHER, null);
$_SESSION['seshToken'] = $token;
如果你'var_dump($ _ SESSION)',它是否包含你之前设置的任何变量?关于'session_id()',你会在所有页面中获得相同的会话ID吗? – Tchoupi 2013-05-09 01:37:36
您可以使用Firebug或Chrome的开发者工具查看发生的请求。检查重定向链中的最后一页是否获得相同的“PHPSESSID”cookie。 – Halcyon 2013-05-09 01:39:29
看到此页我认为你想要传递子域之间的会话http://stackoverflow.com/questions/795414/why-cant-i-pass-user-sessions-between-subdomains和http://stackoverflow.com/questions/ 644920/allow-php-sessions-to-carry-to-subdomains – 2013-05-09 01:53:06