PHP P4 session function Comments (1) _ PHP Tutorial

Source: Internet
Author: User
Session function of php4 (1 ). Php4 is added with session support over php3. I used it a little bit and made a rough understanding of its function interfaces, internal mechanisms, and convenience of applications. The meaning of the session should be clear to everyone. a new version of php4 is supported by the session than php3. I used it a little bit. for its function interface, internal mechanism,
I have a rough understanding of the ease of application.
The meaning of a session should be clear. a session can contain http requests and responses several times,
For example, if we use 163.net, from login to logout or timeout, we use it as a session, session
Generally, a unique session ID is generated within the system.
String. In addition to the session ID, a session can also have its own session data.
Record and differentiate different states of the sesion.

Php4 provides the following APIs for session operations:

Session_start-Initialize session data
Session_destroy-Destroys all data registered to a session
Session_name-Get and/or set the current session name
Session_module_name-Get and/or set the current session module
Session_save_path-Get and/or set the current session save path
Session_id-Get and/or set the current session id
Session_register-Register a variable with the current session
Session_unregister-Unregister a variable from the current session
Session_is_registered-Find out if a variable is registered in a session
Session_decode-Decodes session data from a string
Session_encode-Encodes the current session data as a string

Meaning you can understand at a glance that session_start starts a session and session_destroy ends
End a session, session_id to get the current session_id, session_register to the current
Session to register a variable. this is very useful, for example, when a user visits a mall and selects a few items for you.
You can use session_register to send the product name or code to the current session.

For example, the following example (from php manual ):

Session_register ("count ");
$ Count ++;
?>

Hello visitor, you have seen this page Times.


# Is necessary to preserve the session id
# In the case that the user has disabled cookies

To continue, "> click here

Session_register can implicitly stimulate session_start (if the user has not sent a session before _
The current session registers a variable count. each time you click here
This variable will be added. You can try it on your own. The meaning is not repeated.

Bytes. I used it a little bit and made a rough understanding of its function interfaces, internal mechanisms, and convenience of applications. The meaning of session should be clear to everyone...

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.