Review of the session function of php4 (1)_PHP tutorial

WBOY
Release: 2016-07-21 16:04:59
Original
842 people have browsed it

PHP4 has new session support than PHP3. After using it for a while, I got a general understanding of its function interface, internal mechanism, and
convenience of application.
Everyone should know the meaning of session. A session can include several http requests and responses.
For example, if we use 163.net, from login to logout or timeout is regarded as a session. The only thing about session
The identification is generally a unique session ID generated within the system, which is usually a very long
string. In addition to the session ID, a session can also have its own session data, which can
record and distinguish different statuses of the session.

php4 provides the following interfaces 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

The meaning can be understood at a glance. session_start starts a session, session_destroy ends
ends a session, session_id gets the current session_id, and session_register registers with the current session
A variable, this is very useful. For example, when a user visits a mall and selects certain products, you
can use session_register to register the product name or code into the current session.

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

session_register("count");
$count++;
?>

Hello visitor, you have seen this page times.


# the is necessary to preserve the session id
# in the case that the user has disabled cookies

To continue, click here

session_register can implicitly trigger session_start (if the user has not issued a session_
start call before). The current session registers a variable count. Every time the user clicks click here
, this variable will increase by one. You can try it yourself. The meaning of is not detailed here.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315851.htmlTechArticlePHP4 has added session support compared to php3. After using it for a while, I got a general understanding of its function interface, internal mechanism, and convenience of application. Everyone should know the meaning of session, one...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!