Regarding the PHP tutorial, we talked about cookie parameter passing in the last issue of Zhutou. It was March. This section brings you important session parameter passing.
1. What is session parameter passing?
Session is similar to cookies and is used to store user-related information. For example, common: when you browse different pages of a website, your identity authentication information can be saved, which is achieved by using this parameter.
2. The difference with cookies
session is to store data on the server (through the unique identifier SessionID), while cookies are fragments of information sent by the server to the client, and are stored in the memory of the client's browser or on the hard drive.
3. Session usage steps
1. Set up Session:
This step is very simple, just assign a value to the session variable. For example:
$_SESSION["username"]="Pig's Head";
(Of course, this is the assignment when there is no interaction with the database. In daily development, there is more than one value for Pig's Head, and it is generally replaced by the variable $username)
2 .Read Session:
Use PHP predefined array $_SESSION to obtain, such as:
$_SESSION["username"] ;
3. Delete Session:
Use session_unregister() function to unregister the specified variable. If you want to delete all Session variables, first use session_unset() to release all Session variables, but the SessionID still exists at this time, and we can use session_destroy() to completely destroy it. Such as:
header(“content-Type: text/html; charset=utf-8″);
session_start();
session_unregister(“username”);
session_unset();
session_destroy() ;
header("Refresh:5;url=login_form.php");
echo "You have safely exited the user center";
?>
Note:
Before using session, you must first use session_start () function opens the session and must be placed before all session operations. Otherwise, the session will not be usable.
Conclusion of this section:
Learning PHP, not to mention becoming a PHP master, but mastering basic PHP development technology is still relatively easy, and this will have many benefits for you to modify wordpress, DZ, and dede templates. . If you want to learn, start with the introduction to PHP syntax, dear.
The above is the content of session state control (2) in PHP. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
