微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Php会话文件权限

我有文件index.PHP

<?PHP    
session_start();
$_SESSION['favcolor'] = 'green';

我得到了结果:

Warning: session_start() [function.session-start]: open(/tmp/sess_a8njkmbcg3lbkvl7f2hhjchjm5, O_RDWR) Failed: Permission denied (13) in /var/www/test.local/index.PHP on line 9
Warning: UnkNown: open(/tmp/sess_a8njkmbcg3lbkvl7f2hhjchjm5, O_RDWR) Failed: Permission denied (13) in UnkNown on line 0
Warning: UnkNown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in UnkNown on line 0

PHP.ini中

root@savpc:/etc/PHP5/apache2# cat PHP.ini | grep '^session'
session.save_handler = files
session.save_path = "/tmp"
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = PHP
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5

文件系统中,我获得具有奇怪权限的文件

root@savpc:/tmp# ls -al | grep 'sess' 
----------  1 www-data www-data  2106 2013-11-11 19:21 sess_7cvcojv36n6se6mkrqmui7tu707u9avb
----------  1 www-data www-data    21 2013-11-11 19:23 sess_a8njkmbcg3lbkvl7f2hhjchjm5
----------  1 www-data www-data  1040 2013-11-11 19:21 sess_gllhhosb9dur0jdvf13lqe5klmebj1k9
----------  1 www-data www-data  2106 2013-11-11 19:21 sess_m8c788u0jssqg1gqjeonafk0er5jnbsk

> Ubuntu 11.10
> Apache版本:Apache / 2.2.20(Ubuntu)
> PHP版本5.3.6-13ubuntu3.10

可能是什么问题?

解决方法:

>使用特定文件夹进行会话,例如/ tmp / PHP_sessions.出于安全考虑,这既是保持良好的家务.
>尝试在session.save_path中指定文件模式.

session.save_path = "0;0600;/tmp/PHP_sessions"

有关详细信息,请参见session configuration in the PHP manual.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐