问题:重定向后会话变量不会延续。
facebook.php(会话变量创建并存储)
按钮指向available.php - > searching.php
我正在使用标题重定向。所以$ _SESSION ['seshfbId']回声在available.php而不是search.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;
答案 0 :(得分:0)
解决。因为我怀疑opentok API与我的sesh变量冲突,因为它调用了会话变量。我将所有会话变量移动到一个php并解决了问题。