Frequently asked Questions _php tutorials for first Use session

Source: Internet
Author: User
Tags php session
Maybe every beginner in PHP will encounter the same problem when using the session, that is
Warning:open (/tmp/sess_7a8c81039d7cba3f9a868bc90f821526, O_RDWR) failed:m (2) in your_php_file_pathsession.php on Line 2

This is not your PHP version is not high enough, not a syntax error, but the PHP specified to hold the session file path does not exist. The following is about the use of the session and my initial experience some feelings, I hope that beginners to take a few detours.

PHP session information is written on the server side of the hard disk, by default, the/tmp directory, if you do not have this directory on your hard disk, you will have the above mentioned error message, there are two ways to solve this, one is to create a directory called TMP on the root directory, the second is a system-provided session The _save_path () function re-assigns an existing directory. PHP and ASP processing session in different ways, ASP is to write the session to the client, the call with a special statement, do not do other processing, and PHP also to initialize a session of the environment. I'll make an introduction to the session in PHP below.

Before using the session, first initialize with session_start () and declare the variable with the Session_register () function, which should be in the form Session_register ("SSP") or Session_register ("$ SSP ") and returns a true value if the declaration succeeds. This variable becomes a session and can be called in other pages.

The method to invoke is as follows: initialization of the session is also performed on the calling page (IBID.), then the variable name can be used directly,



Session_Start: initial session.
Session_destroy: End session.
Session_name: Access the current session name.
Session_module_name: Access the current session module.
Session_save_path: Accesses the current session path.

SESSION_ID: Access the current session code.
Session_register: Register a new variable.
Session_unregister: Delete the registered variable.
session_is_registered: Check if the variable is registered.
Session_decode:session data decoding.
Session_encode:session Data encoding

http://www.bkjia.com/PHPjc/532088.html www.bkjia.com true http://www.bkjia.com/PHPjc/532088.html techarticle perhaps every PHP beginner in the use of the session, will encounter the same problem, that is Warning:open (/tmp/sess_7a8c81039d7cba3f9a868bc90f821526, O_RDWR) failed : M (2) in Your_ ...

  • 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.