dongrendang6566 2017-02-16 18:10
浏览 53
已采纳

一个php会话变量导致重定向的取消设置会话

I am using a combination of Javascript and PHP Facebook sdk to integrate the log in to my website (hosted on localhost).

The code after Facebook initialization and getting the access token:

if(fbidExists($profile['id']) == true)
  {

    $query = "SELECT userid AS id, username FROM users WHERE fbid = ".   $profile['id'] ;

    $login = mysqli_fetch_assoc(mysqli_query($GLOBALS['connection'], $query));

    $_SESSION['id'] = $login['id'];
    $_SESSION['username'] = $login['username'];

    header("Location: http:\\\\localhost\website\\");
    exit();
  }

Problem: After redirect there are no session variables whenever I use $login['username'], otherwise the session variables are transferring.

If I change the SQL query and replace username by any other column there is no problem and I can see the session variables after redirect. For example : $query = "SELECT userid AS id, email FROM users WHERE fbid = ". $profile['id'] ; $_SESSION['username'] = $profile['email'] creates no problem

The $_SESSION['username'] variable can be easily set through other files and creates no problem (when i use it with my own log in)

username in MySQL is of varchar type and I am using session_start() on every page and exit() after header.

  • 写回答

1条回答 默认 最新

  • duanmu5039 2017-02-21 04:35
    关注

    Thanks for all your help. Turns out it was a problem because in the second script one on the variables was not set which was destroying the session.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧