0

Problem: Session variable doesnt carry over after the redirect.

facebook.php (session variable created, and stored)

button directs to available.php --> searching.php

I'm using header redirect. So $_SESSION['seshfbId'] echos on available.php but not searching.php

Code

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'];
?>

EDIT: after vardump i have found seshId and seshToken on the searching page. but the code used to create that is on tac.php. I have a feeling tac.php code clashed with session variables earlier

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;
Sammy Kumar
  • 121
  • 3
  • 15
  • 2
    If you `var_dump($_SESSION)`, does it contain any of the variables you previously set? What about `session_id()`, do you get the same session ID across all pages? – Tchoupi May 09 '13 at 01:37
  • You can use Firebug or Chrome's Developer Tools to look at the requests as they're happening. Check if the last page in that redirect chain gets the same `PHPSESSID` cookie. – Halcyon May 09 '13 at 01:39
  • see this pages i think you want pass session between subdomains http://stackoverflow.com/questions/795414/why-cant-i-pass-user-sessions-between-subdomains and http://stackoverflow.com/questions/644920/allow-php-sessions-to-carry-over-to-subdomains – mohammad mohsenipur May 09 '13 at 01:53
  • Did the vardump, all the session variable is et in facebook.php was correctly dumped on available.php on searching.php its interesting because there are session variables but different ones set from this code on another page. edited question to reflect this new code. – Sammy Kumar May 09 '13 at 01:56
  • 1
    I know i am probably wrong, but to point out what appears obvious have you tried moving the header location to the bottom of setting the variables? – alexander7567 May 09 '13 at 02:56

1 Answers1

0

Resolved. As i suspected the opentok API clashed with my sesh variables because it invoked the session variables. i moved all the session variables to one php and problem solved.

Sammy Kumar
  • 121
  • 3
  • 15