Home  >  Article  >  Backend Development  >  How to solve PHP error WARNING: SESSION_START() [FUNCTION.SESSION-START]

How to solve PHP error WARNING: SESSION_START() [FUNCTION.SESSION-START]

不言
不言Original
2018-06-19 16:18:302378browse

This article mainly introduces the solution to the PHP error WARNING: SESSION_START() [FUNCTION.SESSION-START]. Friends who need it can refer to it.

When doing development, you sometimes encounter problems when operating sessions. This problem: Warning: session_start() [function.session-start]......

System environment: WIN2003 IIS6 PHP5.2.12

An error similar to the following appears in PHP:
Warning: session_start()[function.session-start]: ...... failed: No such file or directory...... etc.,
You can try modifying the php.ini file Change session.auto_start = 0 to session.auto_start = 1
If the problem still exists after restarting IIS,
That is, the session variable requires the system's temporary file space and requires read and write permissions.
Find session.save_path = in php.ini, set a valid folder path,
For example: session.save_path = "c:\php5\session_temp" and add the permissions of the folder so that everyone can Just modify the write permissions.

PHP environment:
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

The error message is as follows:

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

Solution:
Method 1. Comment out
session.save_path = “/var/lib/php/session” in /etc/php.ini
Method 2. Check the apache user and group, and then add the user to the session folder in the group.
Method 3, do not have any output before session_start()!
Then restart Apache;
OK, the problem is solved!

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to solve the problem of undefined index prompted by php

About thinkPHP5 framework settings 404 and Methods for 403 and other http status pages

The above is the detailed content of How to solve PHP error WARNING: SESSION_START() [FUNCTION.SESSION-START]. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn