doushi9376 2010-12-23 01:12
浏览 61
已采纳

在nginx上将数据写入$ _SERVER

For reasons that were not my own, I'm working with an application running on nginx that places a GET variable into PHP's $_SERVER global.

What happens is:

  1. A user logs in with Facebook connect

  2. Facebook passes back the user's session as a JSON encoded GET variable to a callback PHP script

  3. An nginx rule places the GET variable into $_SERVER before the PHP script runs

  4. The PHP script references the variable placed in $_SERVER and uses it to log the user into the site

Despite the fact that this is a bad solution in general, is writing user specific runtime data to a $_SERVER variable even safe on nginx? Would it create any concurrency issues when multiple users are logging into the site?

  • 写回答

1条回答 默认 最新

  • dow46218 2010-12-23 01:55
    关注

    The $_SERVER variable is not shared between users. Each PHP instance has its own copy of the $_SERVER variable. It contains data pertaining to the current request, as such is request specific. You can write to it all you want without concerns, but it really isn't good practice to do so (there is a performance penalty when doing so and it's also rather unorthodox).
    If the server is simply setting environment variables that show up in $_SERVER, that's an acceptable use though. Just don't write to it from your PHP scripts.

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效