这是我的设置。用户可以连接Facebook。然后我使用facebook id在我的用户表中查找id。我想在会话中的表格中添加facebook id和用户标识。然后我将用户重定向到主页面。重定向后丢失会话变量
/*
* Leg til facebook id i session hvis bruker logger in/registrer seg med facebook
*/
$_SESSION['fb_id'] = $fb['id'];
/*
* Set user id
*/
$_SESSION['id'] = $id;
/*
* Auto log-out after 45 minutes
*/
$_SESSION['expires'] = time()+(45*60);
/*
* Log to db
*/
$this->log_login_attempt(true);
/*
* Redirect user to game
*/
$host = $_SERVER["HTTP_HOST"];
header("location: http://$host/homepage.php"); //@ redirect
exit();
如果我重定向之前做一个echo var_dump($_SESSION)
我得到:
array(3) { ["fb_id"]=> string(9) "7683402XX" ["id"]=> int(12) ["expires"]=> int(1303482308) }
所以我将用户重定向到homepage.php
这里我只需要输入:
error_reporting(E_ALL);
ini_set("display_errors", true);
require '../sys/core/errorhandler.php';
set_error_handler('my_error_handler');
$a = session_id();
if ($a == '') session_start();
echo var_dump($_SESSION);
exit();
这导致:
array(2) { ["id"]=> int(12) ["expires"]=> int(1303482647) }
不知何故$_SESSION['fb_id']
消失了?这怎么会发生?