"; //method one // $_SESSION[usernam"/> "; //method one // $_SESSION[usernam">

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

There are three ways to destroy PHP session

WBOY
WBOYOriginal
2016-07-28 08:27:141259browse
<?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'];

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.

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