Home > Article > Backend Development > Introduction to PHP session processing related functions
PHPProcessing session functions 1, session_start
Function 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 2
, session_register
Function function: Register a new variable as a session variableFunction 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 a logical value
true . You can use the form $_SESSION[name] or $HTTP_SESSION_VARS[name] to get or assign a value. PHPProcessing session functions 3
, session_is_registered
Function 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 current session already has the specified one Variable registration, the parameter
name is the variable name to be checked. If successful, the logical value
true is returned. PHPProcessing session functions 4
, session_unregister
Function 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. If successful, it returns
true. PHPProcessing session functions 5
,
session_destroyFunction function: End the current session and clear all resources in the session. Function prototype: boolean session destroy(void);
Return value: Boolean value.
Function description: This function ends the current session. This function has no parameters, and the return value is
true.
PHPProcessing session functions 6
, session_encode
Function functions: sesssionInformation encoding Function prototype:
string session_encode(void ; it is a test”;c|s:4:”
lala”; a
is the variable name s:12
represents the value of the variable a The length of "it is a test is 12 variables are separated by semicolons ";". PHP processing session function 7 , session_decodeFunction function: sesssionInformation decoding
Function prototype: boolean session_decode (string data)
Return value: Boolean value Function Description: This The function can decode the session information and return the logical value
true if successful. 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 there is no parameter name, it means getting the name of the current session, and adding the parameter means setting the sessionname as the parameter name.
PHPProcessing session functions9, 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 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 session to the newly specified id.
PHPProcessing session functions 10, session_unset
Function function: Delete all registered variables.
Function prototype: void session_unset (void)
Return value: Boolean value
Function description: This function is different from Session_destroy, it does not end the session. Just like using the function session_unregister to unregister all session variables one by one.
Get it for freeLAMPBand of BrothersOriginalPHPTutorialCD/ 《DetailsPHP 》Essential version, please contact the official website customer service for details: http://www.lampbrother.net
PHPCMSSecondary developmenthttp://yun.itxdl.cn/online/phpcms /index.php?u=5
WeChat developmenthttp://yun.itxdl.cn/online/weixin/index.php?u=5
Mobile Internet server side Developmenthttp://yun.itxdl.cn/online/server/index.php?u=5
JavascriptCourseshttp://yun.itxdl.cn /online/js/index.php?u=5
CTOTraining Camphttp://yun.itxdl.cn/online/cto/index.php?u=5
The above has introduced the functions related to PHP session processing, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.