Several common session functions in php

小云云
Release: 2023-03-17 16:22:01
Original
1784 people have browsed it

In computer terminology, Session refers to the time interval between an end user communicating with an interactive system, usually referring to the time elapsed from registering to enter the system to logging out of the system. And there may be some room for maneuver if needed. In this section, we share with you several common Session functions that you must know in PHP.

session_start():

Start the session, there is nothing to say about this. Open the session file based on the session ID. If there is no session ID, create an ID and corresponding session file.

$SESSION[]:

A global array that stores user information. In addition to storing the data in $SESSION, the session file also stores other information, such as id, etc.

sessionunset():

Clear the $SESSION array. It clears the values ​​in the array, but the variable $SESSION still exists, which is completely different from unset($SESSION). concept.

sessioncommit():

Submit session data and end the session, write $SESSION data to the file and end the session. In fact, when a page is executed, PHP will automatically perform the same operation as this function. Therefore, this function is rarely used

session_destroy():

Log out the session. This is to close the session and delete the corresponding session file. Cut off the connection between client and server.

The above are a few commonly used session functions, I hope they will be helpful to everyone.

Related recommendations:

Destruction of PHP session variables

The definition and difference between cookie and session

PHP’s SESSION mechanism analysis

The above is the detailed content of Several common session functions in php. For more information, please follow other related articles on the PHP Chinese website!

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