无法创建SESSION

时间:2015-09-18 07:35:04

标签: php json session

[[NSFont systemFontOfSize:13] fontDescriptor]

我检查了这个代码10次(至少),但我不明白它为什么不创建<?php ob_start(); session_start(); require ('openid.php'); function logout() { echo '<form action="logout.php" method="post"><button class="btn btn-danger" type="submit"><i class="fa fa-power-off"></i> Log Out</button></form>'; //logout button } function steamlogin() { try { require("settings.php"); $openid = new LightOpenID($domain); if(!$openid->mode) { if(isset($_GET['login'])) { $openid->identity = 'http://steamcommunity.com/openid'; header('Location: ' . $openid->authUrl()); } return "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_noborder.png\"></form>"; } elseif($openid->mode == 'cancel') { echo 'User has canceled authentication!'; } else { if($openid->validate()) { $id = $openid->identity; $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/"; preg_match($ptn, $id, $matches); $steamid = $matches[1]; $link = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$key."&steamids=".$steamid.""); $decode = json_decode($link); $newlink = $decode->response->players->profileurl; $xml = simplexml_load_file($newlink."?xml=1"); @$custom = $xml->customURL; if(strlen($custom) <= 4){ $user = $xml->steamID64; } else { $user = $custom; } $_SESSION['steamid'] = $user; //Determine the return to page. We substract "login&"" to remove the login var from the URL. //"file.php?login&foo=bar" would become "file.php?foo=bar" $returnTo = str_replace('login&', '', $_GET['openid_return_to']); //If it didn't change anything, it means that there's no additionals vars, so remove the login var so that we don't get redirected to Steam over and over. if($returnTo === $_GET['openid_return_to']) $returnTo = str_replace('?login', '', $_GET['openid_return_to']); header('Location: '.$returnTo); } else { echo "User is not logged in.\n"; } } } catch(ErrorException $e) { echo $e->getMessage(); } } 。你能救我吗?

我编辑了第一篇文章!

1 个答案:

答案 0 :(得分:0)

首先,你应该尝试设置虚拟数据来测试你的会话是否正常工作。在你的session_start()之后加上一行

$_SESSION['test'] = 'test';
var_dump($_SESSION);

如果密钥在整个请求中没有持久存在,则表示会话处理程序存在问题(可能缺少写入权限)。

如果您的会话正在运行,那么您开始沿着逻辑树开始,检查每个if语句中的表达式以查看执行路径是什么,您不提供任何当前输出,因此我无法立即告诉。

这不是一个明确的答案,但我相信如果你听从我的建议,你就会找到问题的根源。

相关问题