Home > Backend Development > PHP Tutorial > There are three ways to destroy PHP session

There are three ways to destroy PHP session

WBOY
Release: 2016-07-28 08:27:14
Original
1263 people have browsed it
<?php
/* session的销毁 */
@header(&#39;content-type:text/html;charset=utf-8&#39;);
session_start();


$_SESSION[&#39;username&#39;]=&#39;test1&#39;;
echo &#39;session没销毁时:&#39;.$_SESSION[&#39;username&#39;];
echo "<br>";
//方法一
// $_SESSION['username']=null;
//方法二
//session_unset();
//session_destroy();
//方法三
$_SESSION=array();
echo 'session销毁后:'.$_SESSION['username'];
Copy after login

The above introduces the three methods of destroying PHP sessions, including the relevant contents. I hope it will be helpful to friends who are interested in PHP tutorials.

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