Introduction to php session processing function

伊谢尔伦
Release: 2023-03-02 19:38:01
Original
912 people have browsed it

Introduction to php session processing function

PHP session processing function 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

PHP processing session function 2, session_register

function function: register a new variable For session variables

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 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 the variable name to be checked. If successful, the logical value true is returned.

PHP processing session function 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, and returns true if successful.

PHP processing session function 5. session_destroy

Function 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.

PHP processing session function 6. session_encode

Function function: sesssion information encoding

Function prototype: string session_encode(void);

Return value: string

Function description: The returned string contains global variables The name and value of each variable in, in the form: a|s:12:”it is a test”;c|s:4:”lala”; a is the variable name and s:12 represents the value of variable a”it is a The length of test is 12. Variables are separated by semicolon ";".

PHP processing session function 7. session_decode

Function function: session information decoding

Function prototype: boolean session_decode (string data)

Return value: Boolean value

Function description: This function can decode the session information and return the logical value true if successful.

PHP processing session function 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 there is no parameter name, it means getting the current session name. Adding the parameter means changing the session name. Set as parameter name.

PHP processing session function 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 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 the newly 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

Function description: This function is different from Session_destroy. Not ending the session is like using the function session_unregister to log out all session variables one by one

.
Related labels:
php
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