search
Homephp教程PHP开发Destruction of session variables in PHP

1.What is session?
Equivalent to a client (can be a browser, app, ftp, etc., and if you open several more clients in the same browser, they are considered different clients), during this period the server establishes a unique identifier for this purpose (session_id session_name), in fact, it is an array Array(). The beginning and end of the Session does not start with entering the user name and password in the business, nor does it end with closing the browser and refreshing the web page

2. Destruction of session variables
Program code
session_unset();
session_destroy();
?>

session_unset()
Release all $_SESSION variables currently created in memory, but do not delete the session file and do not release the corresponding The session id

session_destroy()
deletes the session file corresponding to the current user and releases the session id. The content of the $_SESSION variable in the memory is still retained

[Note]:

Delete session method:

1. unset ($_SESSION ['xxx']) deletes a single session, unset($_SESSION['xxx']) is used to unregister a registered session variable. Its function is the same as session_unregister(). session_unregister() is no longer used in PHP5 and can be relegated to obsolescence.

unset($_SESSION) This function must not be used, it will destroy the global variable $_SESSION, and there is no feasible way to restore it. Users can also no longer register the $_session variable.

2. $_SESSION=array() deletes multiple sessions

3. session_destroy() ends the current session and clears all resources in the session. . This function will not unset (release) global variables related to the current session, nor will it delete the client's session cookie. PHP's default session is based on cookies. If you want to delete cookies, you must use the setcookie() function.

Return value: Boolean value.

Function description: This function ends the current session. This function has no parameters, and the return value is true

session_unset() If $_session is used, this function will no longer work. Since PHP5 must use $_session, this function can be relegated to the sidelines.

The steps to delete session can be drawn:

①session_start()

②$_SESSION=array()/unset($_session['xxx'])

③session_destroy()


More sessions in PHP For articles related to the destruction of variables, please pay attention to the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools