Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP会话丢失,suhosin不可更改_Php_Session_Suhosin - Fatal编程技术网

PHP会话丢失,suhosin不可更改

PHP会话丢失,suhosin不可更改,php,session,suhosin,Php,Session,Suhosin,在Ubuntu12.04、Apache2、PHP5服务器上安装了suhosin扩展。() 这是一个通过自动更新提供最新安全更新的专用服务器 我已经创建了以下测试脚本() 错误日志显示: [Sat Oct 26 20:00:23 2013] [error] [client 103.29.31.35] Old 'suhosin.session.encrypt': [Sat Oct 26 20:00:23 2013] [error] [client 103.29.31.35] Old 'suhosi

在Ubuntu12.04、Apache2、PHP5服务器上安装了suhosin扩展。()

这是一个通过自动更新提供最新安全更新的专用服务器

我已经创建了以下测试脚本()

错误日志显示:

[Sat Oct 26 20:00:23 2013] [error] [client 103.29.31.35] Old 'suhosin.session.encrypt': 
[Sat Oct 26 20:00:23 2013] [error] [client 103.29.31.35] Old 'suhosin.session.cryptdocroot': 
[Sat Oct 26 20:00:23 2013] [error] [client 103.29.31.35] Old 'suhosin.cookie.cryptdocroot.'
其他SO帖子建议检查session.cookie\u secure和session.http\u only参数。这台服务器上的两个都已关闭。此外,我还尝试实现关闭特定的suhosin设置,或者使用suhosin.simulation=On关闭suhosin,我在php.ini中都尝试过

此脚本返回fail。如果使用is=set参数运行脚本,则无法设置参数()

在另一台专用服务器上,测试脚本可以正常工作,即https url会拾取会话变量,但此服务器是Ubuntu 10.04


知道下一步要做什么吗?

您试图更改的选项(例如,
suhosin.cookie.cryptdocroot
)会影响suhosin在脚本开始运行之前所做的事情。因此,在运行时更改它们是没有意义的-您需要在
php.ini
或类似程序中设置它们。

session\u start()
必须在输出任何内容之前调用,因此在
如果($\u GET['is']='set')
块中,
print
调用阻止会话启动。如果没有这一点,
$\u会话['test']
将永远不会持续足够长的时间,以使您的
if($\u会话['test']='abc')
块测试为真编辑:所有标题必须在任何输出之前发送(这也是必须在之前调用
会话启动()
的原因)-因此ini\u set块中的
print
调用仍在阻止
标题('location')
调用。如果您需要查看
ini_set()
返回的内容,请通过
error_log(“Old'suhosin.session.encrypt':”)将其值输出到错误日志中。print_r(ini_set('suhosin.session.encrypt',0),true)用于每个配置。或者在发送任何可能的标题后,缓存结果并打印它们

在http和https之间传输也会丢失会话变量,因为它们会启动单独的会话。这个问题应该涵盖你问题的其余部分


对于您的
suhosin…
ini设置,
ini\u set
将返回以前的值-因此,如果ini配置以前是
false
,您将得到
false
,即使调用成功。

最近,为了安全起见,我将HTTP和HTTPS VirtualHost文件合并为一个文件,并将apache服务器更改为MPM-ITK,这也是我自己打破的

在合并的VirtualHost文件中

<VirtualHost 120.138.18.91:80>
    ServerName www.theparentingplace.com

    DocumentRoot /var/www/www.theparentingplace.com/joomla
    CustomLog /var/log/apache2/www.theparentingplace.com-access.log   combined
    ErrorLog /var/log/apache2/www.theparentingplace.com-error.log

<IfModule mpm_itk_module>
    AssignUserId www-theparentingplace www-theparentingplace
</IfModule>

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^.*=(ht)|(f)+(tp)+(://|s://)+.*(\?\?)+
    RewriteRule .* http://gggooooooglleee.com/ [R,L]

    <FilesMatch "images/\.(asp|php|php5|pl)$">
        Deny from all
    </FilesMatch>
</VirtualHost>

<VirtualHost 120.138.18.91:443>
ServerName www.theparentingplace.com
    DocumentRoot /var/www/www.theparentingplace.com/joomla

CustomLog /var/log/apache2/www.theparentingplace.com-ssl-access.log combined
ErrorLog /var/log/apache2/www.theparentingplace.com-ssl-error.log

<IfModule mpm_itk_module>
    AssignUserId www-theparentingplace www-theparentingplace
</IfModule>

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/www.theparentingplace.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
    SSLCertificateChainFile /etc/apache2/ssl/www.theparentingplace.com.ca.crt

BrowserMatch ".*MSIE.*" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0

   RewriteEngine On
   RewriteCond %{QUERY_STRING} ^.*=(ht)|(f)+(tp)+(://|s://)+.*(\?\?)+
   RewriteRule .* http://gggooooooglleee.com/ [R,L]

   <FilesMatch "images/\.(asp|php|php5|pl)$">
       Deny from all
   </FilesMatch>
</VirtualHost>

服务器名www.theparentingplace.com
DocumentRoot/var/www/www.theparentingplace.com/joomla
CustomLog/var/log/apache2/www.theparentingplace.com-access.log
ErrorLog/var/log/apache2/www.theparentingplace.com-error.log
分配用户ID www the parentingplace www the parentingplace
重新启动发动机
重写cond%{QUERY\u STRING}^.*=(ht)|(f)+(tp)+(:/| s:/)+*(\?\?)+
重写规则。*http://gggooooooglleee.com/ [R,L]
全盘否定
服务器名www.theparentingplace.com
DocumentRoot/var/www/www.theparentingplace.com/joomla
CustomLog/var/log/apache2/www.theparentingplace.com-ssl-access.log
ErrorLog/var/log/apache2/www.theparentingplace.com-ssl-error.log
分配用户ID www the parentingplace www the parentingplace
斯伦金安
SSLCertificateFile/etc/apache2/ssl/www.theparentingplace.com.crt
SSLCertificateKeyFile/etc/apache2/ssl/server.key
SSLCertificateChainFile/etc/apache2/ssl/www.theparentingplace.com.ca.crt
浏览器匹配“*MSIE.*”\
nokeepalive ssl不干净关闭\
降级-1.0力响应-1.0
重新启动发动机
重写cond%{QUERY\u STRING}^.*=(ht)|(f)+(tp)+(:/| s:/)+*(\?\?)+
重写规则。*http://gggooooooglleee.com/ [R,L]
全盘否定
我忘了加上

<IfModule mpm_itk_module>
    AssignUserId www-theparentingplace www-theparentingplace
</IfModule>

分配用户ID www the parentingplace www the parentingplace
阻止访问安全站点部分,因此https站点无法读取会话文件


感谢Brian North,他让我想到检查我是否可以强制使用https会话id(我无法使用错误的配置)

您有什么特别的原因试图设置三次
suhosin.session.cryptocRoot
?感谢您的帮助,第一个应该是suhosin.session.encrypt,另一个是cookie.cryptdocroot,session.cryptdocroot。我已经在现场更新了脚本并重新测试。问题是我无法关闭任何这些设置。为什么?会话启动()之后的会话设置cookie参数毫无意义。是session_start()写入设置会话ID cookie的标题。谢谢,我们已将session_start移到顶部。在php.ini中,3个suhosin设置实际上被设置为Off,因此您可能完全正确。我可能用suhosin做了错误的事情,我想解决的问题是http和https之间的会话丢失。如果ini.php中的那些设置关闭,那么
ini\u set()
函数将为它们返回false。要在http和https之间持久化同一会话,问题在于PHP和您的服务器将它们视为启动单独的会话。我上次编辑中包含的问题/答案解决了这个问题。基本上,在进行切换时,您必须手动传递会话id。我已经看到了这个答案,但它根本不正确。除非设置了其他参数,否则HTTP和HTTPS之间不会丢失会话变量。我在另一台服务器上运行了这个程序,会话没有丢失:P.S.看到了您最后的评论,但不正确。您的
session\u set\u cookie\u params
调用将
$domain
参数设置为
'
-当您传递它时会发生什么。theparentingplace.com“<代码>会话设置cookie参数('3600','/
<IfModule mpm_itk_module>
    AssignUserId www-theparentingplace www-theparentingplace
</IfModule>