Session and cookie configuration in php. ini

Source: Internet
Author: User

This article describes session and cookie configurations in php. ini. I hope this tutorial will be helpful to you.

1, session. use_cookie = 1

Whether to use the Cookie method to pass the session id value. The default value is 1, indicating that it is enabled.

2, session. name = PHPSESSID

The key value is required for Cookie-based sessioin_id or GET-based session_id. Their formats are Cookie: sess_name = session_id; And/path. php? Sess_name = session_id, where sess_name is specified here.

3, session. use_only_cookies = 0

Indicates that only session IDs are transmitted using the Cookie method. As we have said, in addition to cookies, there are also GET methods. The GET method is insecure. When the cookie is disabled on the user side, session_id is transmitted using the GET method. You can use the GET method to pass session_id through this setting.

4. session. cookie_lifetime = 0, session. cookie_path =/, and session. cookie_domain =
If you use the Cookie method to pass session_id, the valid cookie domain, directory, and time are specified. Corresponds to $ expire, $ path, and $ domain of the setcookie () function. Cookie_lifetime = 0 indicates that the Cookie is not deleted until the browser is closed. You can also use the session_set_cookie_params () function to modify these values.

5, session_name ([string $ name])

Obtains or updates session_name. If the name is passed, the default name PHPSESSID (specified by session. name) is not used. Otherwise, the current session_name is obtained. NOTE: If session_name is set, the call takes effect only before session_start.

6, session_id ([string $ id])

Similar to session_name (), but it is the method for reading or setting session_id. Similarly, if session_id is set, it must be called before session_start.

7. session_set_cookie_params () and session_get_cookie_params ()

Session. cookie_lifetime, session. cookie_path, and session. cookie_domain can be reset through session_set_cookie_params. Session_get_cookie_params () is used to obtain these set values.

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.