PhP4 is added with session support over 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 set the product name orCodeRegister to the current session.
For example, the following example (from PhP manual ):
<? PHP
Session_register ("count ");
$ Count ++;
?>
Hello visitor, you have seen this page <? Echo $ count;?> Times. <p>
# The <? = Sid?> Is necessary to preserve the session ID
# In the case that the user has disabled cookies
To continue, <a href = "nextpage. php? <? = Sid?> "> Click here </a>
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. <? = Sid?> The meaning is not repeated.