Home >Backend Development >PHP Tutorial >Summary of PHP session function processing_PHP tutorial
Everyone is learning
When the client's cookies are disabled, they will be automatically passed through Query_String. There are a total of 10 PHP session processing functions. Let's introduce in detail several functions that will be used.
PHP session processing function 1. session_start
Function: Start a session or return an existing session.
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 best to put this function first, and there must be no output before it, otherwise an alarm will be issued, such as: Warning: Cannot send session cache limiter – headers already sent (output started at /usr/local/apache/htdocs/cga /member/1.php:2) in /usr/local/apache/htdocs/cga/member/1.php on line 3
PHP processing session function 2, session_register
Function function: Register a new variable as a session variable
Function prototype: boolean session_register(string name);
Return value: Boolean value.
Function description: This function adds a variable to the current SESSION in the global variable. The parameter name is the name of the variable you want to add. If successful, it returns the logical value true. You can use the form $_SESSION[name] or $HTTP_SESSION_VARS[name] to get or assign a value.
PHP processing session function 3. session_is_registered
Function: Check whether the variable is registered as a session variable.
Function prototype: boobean session_is_registered(string name);
Return value: Boolean value
Function description: This function can check whether the specified variable has been registered in the current session. The parameter name is what needs to be checked. variable name. If successful, the logical value true is returned.
PHP processing session function 4. session_unregister
Function: Delete registered variables.
Function prototype: boolean session_session_unregister(string name);
Return value: Boolean value
Function description: This function deletes variables in global variables in the current session. The parameter name is the name of the variable to be deleted, and returns true if successful. all resources in .
Return value: Boolean value. Function description: This function ends the current session. This function has no parameters, and the return value is trueThe functions introduced above will be used later, but there are also some functions related to the session that are also introduced:
PHP processing session function 6. session_encode
Function: session information encoding
Return value: stringFunction description: The returned string contains the name and value of each variable in the global variable, in the form: a|s:12:”it is a test”;c|s:4:”lala”; a is a variable The name s: 12 represents the value of variable a "the length of it is a test is 12 and the variables are separated by semicolon ";".
PHP processing session function 7, session_decode
Function function: decoding session information
Return value: Boolean valueFunction description: This function can decode session information and return the logical value true
PHP processing session function 8. session_name
Function function: access the current session name
Return value: String Function description: This function can get or reset the name of the current session. If there is no parameter name, it means to get the current session name. Adding the parameter means setting the session name to the parameter name<.>
PHP session processing function 9. session_id
Function function: access the current session identification number
Function prototype: boolean session_id(string [id]);
Function description: This function can obtain or reset the identification number of the currently stored session. If there is no parameter id, it means only getting the identification number of the current session. Adding the parameter means setting the identification number of the session to a new one. Specified id
PHP processing session function 10. session_unset
Function function: Delete all registered variables.
Function prototype: void session_unset (void)<.>Return value: Boolean value
http://www.bkjia.com/PHPjc/446118.html
www.bkjia.com
http: //www.bkjia.com/PHPjc/446118.html