PHP Startup session Failure Exception resolution method

Source: Internet
Author: User
Tags temporary file storage
PHP Startup session Failure Error resolution

Original address: http://www.hjaa.net/?p=1149

PHP Startup session Failure error reason should be: PHP.ini, about the session part of the settings there is an error, raised session?cookies cannot send and hold.

Troubleshooting steps:

1, save the following text as phpinfo.php, and upload to the server to be able to access, such as the site http://www.hjaa.net/phpinfo.php

Phpinfo ();

?>

Focus on the session section

2, Session.cookie_domain set up a domain name, that is, session.cookie_domain?=? A domain name result causes Session?cookies to expire in the B domain.

Workaround 1: Set the session.cookie_domain in php.ini to null, i.e.: session.cookie_domain?=

Workaround 2:session.cookie_domain?= Set the domain name you use

3, php.ini, Session.cookie_path set too strict. For example, set to: session.cookie_path?=?/hjaa/that is to allow only the root domain name below the Hjaa directory and subdirectories to use the session (more specifically, if Session.cookie_domain set a domain name, Indicates that the HJAA directory and subdirectories under the a domain are allowed to use the session)

Workaround: Set the Session.cookie_path in php.ini to "/" (without double quotes) or the more lenient security settings you think, such as:? session.cookie_path?=?/

4, PHP.ini, will Session.cookie_path and Session.save_path mix, thought Session.cookie_path is the session temporary file storage path. But in fact Session.cookie_path is the site domain that indicates that the session takes effect, and the server's file permissions are irrelevant; Session.save_path is the path to set the session temporary file store. For example, set Session.cookie_path to: Session.cookie_path?=? C:/windows/temp cause a failure.

5, Session.save_path set directory does not have write permission, or is not set correctly (for example, the Set folder does not exist at all). Note: If empty, the default system Temp folder path is used. Windows is generally "%systemroot%\temp" and UNIX is generally "/tmp"

Workaround:

(1), if Session.save_path is not left blank, make sure that the setting value corresponds to a folder, and that the folder exists. If you do not know how to set it, note this setting, or change to a null value, and let PHP use the default settings.

(2), in the corresponding directory, give the corresponding user write permissions, such as for IIS, you should give the Internet Guest account Write permissions.

6, when Session.auto_start = on, Execution session_start () will produce a new Session_idsession.auto_start = On the advantage is that at any time will not be forgotten to perform session_start () or session_start () the position in the program is incorrect, and the disadvantage is that if you are using a third-party code, you must delete all of the session_start (). Otherwise you won't get the right results.

Workaround:

(1) Session.auto_start = Off

(2) The Session_Start of the program ();

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.