做開發的時候,操作session有時候會遇到這個問題:Warning: session_start() [function.session-start]……
PHP環境:
OS:CentOS release 5.2 (Final)
Apache:
Server version: Apache/2.2.3
Server built: Jan 15 2008 20:33:30
php:
PHP 5.1.6 (cli) (built: May 24 2008 14:07:53)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
報錯信息如下:
復制代碼 代碼如下:
Warning:session_start()[function.session-start]:open(/var/lib/php/session/sess_itqfqua1554rmkgcb8u89ujem5,O_RDWR)failed:Permission denied(13)in www_path on line 9
Warning:Unknown:open(/var/lib/php/session/sess_itqfqua1554rmkgcb8u89ujem5,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.sav_path is correct (/var/lib/php/session)in Unknown on line 0
解決辦法:
方法1、注釋掉/etc/php.ini中
session.save_path = “/var/lib/php/session”
方法2、查看apache用戶和組,然後將該用戶加到session文件夾所處的組中。
方法3,在session_start() 前不要有任何輸出!
然後重啟Apache;
OK,問題解決!