A review of the session function of PhP4 (i.)

Source: Internet
Author: User
Tags count session id
PHP4 a new session of support than PHP3. A little bit, on its function interface, the internal mechanism,
The convenience of the application made a general understanding.
The meaning of the session it should be clear to everyone that a sessions can include several HTTP requests and responses,
For example, we use 163.net, from login to logout or timeout as a session,session
The unique identification is typically generated within the system a unique session ID, typically a very long
String. A session in addition to the session ID, you can also have their own session data, you can
Record and distinguish the different states of the sesion.

PHP4 provides the following interface to the session operation:

Session_start-initialize Session Data
Session_destroy-destroys all data registered to a
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
Session_is_registered-find out if a variable be registered in a
Session_decode-decodes session data from a string
Session_encode-encodes the current session data as a string

Meaning everyone can see it, session_start start a Session,session_destroy knot
Bundle a session,session_id to get the current session_id,session_register to the current
Session to register a variable, this is very useful, such as users go shopping malls, selected a certain number of goods you
You can use Session_register to put the product name or code register into the current session.

For example, the following example (excerpt from PHP manual):

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

Hello visitor, 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 fire session_start (if the user has not previously sent Session_
Start call), the current session registers a variable count, each time the user clicks click here
, this variable will increase by one. You can try it on your own. The meaning of <?=SID?> is not much to repeat.


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.