2013-05-09 29 views
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; 
+2

如果你'var_dump($ _ SESSION)',它是否包含你之前設置的任何變量?關於'session_id()',你會在所有頁面中獲得相同的會話ID嗎? – Tchoupi 2013-05-09 01:37:36

+0

您可以使用Firebug或Chrome的開發者工具查看發生的請求。檢查重定向鏈中的最後一頁是否獲得相同的「PHPSESSID」cookie。 – Halcyon 2013-05-09 01:39:29

+0

看到此頁我認爲你想要傳遞子域之間的會話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

回答

0

解決。正如我懷疑opentok API與我的sesh變量衝突,因爲它調用了會話變量。我把所有的會話變量都移到了一個php中,問題解決了。