A session about PHP

Source: Internet
Author: User

from:http://blog.csdn.net/sayigood/article/details/4850480

Usage of Session in PHP
the session in PHP is using the client's cookie by default. When a client's cookie is disabled, it is passed through query_string automatically.
There are 11 functions in the PHP processing session, and we'll go through a few more functions.
1, Session_Start
function function: Start a session or return a session that already exists.
Function prototype: Boolean session_start (void);
Return Value: Boolean value
Function Description: This function has no parameters and the return value is true. It is better to put this function first, and before it can have no output, otherwise it will alarm, such as: Warning:cannot send session cache Limiter-headers already sent (output started At/us R/local/apache/htdocs/cga/member/1.php:2) in/usr/local/apache/htdocs/cga/member/1.php on line 3
2, Session_register
function function: Register a new variable as a session variable
Function prototype: Boolean Session_register (string name);
Return value: A Boolean value.
Function Description: This function is to add a variable to the current session in the global variable, the parameter name is the name of the variable you want to add, and success returns the logical value TRUE. You can use $_session[name] or $http_session_vars[name] to take the form of a value or assignment.
3, session_is_registered
function function: Check if the variable is registered as a session variable.
Function prototype: Boobean session_is_registered (string name);
Return Value: Boolean value
Function Description: This function checks to see if a specified variable has been registered in the current session, and the parameter name is the variable name to check. Success returns the logical value TRUE.
4, Session_unregister
function function: Delete the registered variable.
Function prototype: Boolean Session_session_unregister (string name);
Return Value: Boolean value
Function Description: This function removes variables from global variables in the current session. The parameter name is the name of the variable you want to delete, and success returns TRUE.
5, Session_destroy
function function: Ends the current session and empties all resources in the session.
Function Prototype: Boolean session destroy (void);
Return value: A Boolean value.
Function Description: This function ends the current session, this function has no parameters and the return value is True
The functions described above will be used, but there are also some functions about the session:
6, Session_encode
function function: sesssion information encoding
Function prototype: string session_encode (void);
return value: String
Function Description: The returned string contains the names and values of the variables in the global variable, in the form of: A|s:12: "It is a test"; C|s:4: "Lala"; A is the variable name s:12 represents the value of variable a "it is a test length is a semicolon between 12 variables"; Separated.
7, Session_decode
function function: sesssion information decoding
Function prototype: Boolean Session_decode (String data)
Return Value: Boolean value
Function Description: This function can decode session information, and success returns logical value TRUE
8, Session_name
function function: Access the current session name
Function prototype: Boolean session_name (string [name]);
return value: String
Function Description: This function can get or reset the name of the current session. If no parameter name is given, the current session name is obtained, plus the parameter indicates that the session name is set to the parameter name
9, session_id
function function: Access the current session identification number
Function prototype: Boolean session_id (string [id]);
return value: String
Function Description: This function can get or reset the identification number of the session currently stored. If no parameter ID means only the identification number of the current session, plus the parameter indicates that the session's identification number is set to the newly specified ID
10, Session_unset
function function: Delete all registered variables.
Function prototype: void Session_unset (void)
Return Value: Boolean value
Function Description: Unlike Session_destroy, this function does not end the session. It's like using the function Session_unregister to unregister all session variables individually.

A session about PHP

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.