[英]How to make REMOTE_USER stick when set in PHP?
I'm doing some custom authentication written in PHP and need to set the REMOTE_USER variable, and make it stick, for use in other applications on the web server. 我正在做一些用PHP编写的自定义身份验证,需要设置REMOTE_USER变量,并使其粘贴,以便在Web服务器上的其他应用程序中使用。
I'm able to set the REMOTE_USER
variable and display it in $_SERVER
, and used apache_setenv()
, but a phpinfo()
call in a second page doesn't list the variable as being set. 我能够设置REMOTE_USER
变量并将其显示在$_SERVER
,并使用apache_setenv()
,但第二页中的phpinfo()
调用不会将变量列为已设置。
The web server is Apache 2 with PHP 5. Any thoughts? Web服务器是带有PHP 5的Apache 2.任何想法?
Addendum: An example situation would be I authenticate a user against a database table and set the REMOTE_USER
variable for them and then send them via proxy to a second server, passing REMOTE_USER
along the proxy, as described here for one system: 附录:一个示例情况是我针对数据库表验证用户并为它们设置REMOTE_USER
变量,然后通过代理将它们发送到第二个服务器,沿着代理传递REMOTE_USER
,如下所述:
http://docs.splunk.com/Documentation/Splunk/4.3.1/Admin/Usesinglesign-onwithSplunk http://docs.splunk.com/Documentation/Splunk/4.3.1/Admin/Usesinglesign-onwithSplunk
Don't use $_SERVER
. 不要使用$_SERVER
。 That variable is populated from the server hosting PHP, and isn't something you should be messing with. 该变量是从托管PHP的服务器填充的,并不是你应该搞砸的东西。
What you're looking for is $_SESSION
. 您正在寻找的是$_SESSION
。
http://php.net/manual/en/features.sessions.php http://php.net/manual/en/features.sessions.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.