In PHP program, completed after logging into the session, when the Log, you need to release the session, the corresponding code is shown below.
<?php
session_start();
if(isset($_SESSION["uid"])) // 检测变量是否设置
{
session_unset(); // 释放当前在内存中已经创建的所有$_SESSION变量,但是不删除session文件以及不释放对应的session id;
session_destroy(); // 删除当前用户对应的session文件以及释放session id,内存中$_SESSION变量内容依然保留;
}
header("location:login.php"); // 重定向到登录界面
?>
have to be aware of is:
session_unset();
The release of all $ _SESSION variables currently in memory has been created, but does not delete the session file and does not release the corresponding session id;session_destroy();
Delete files in the current user session and release the corresponding session id, the memory still retains the $ _SESSION variable content;
Related articles: "PHP language website login function"
Author: Dai Xiang
E-mail: [email protected]
micro-channel Developer Home: Null
Description: Chinese citizens, CSDN blog expert, Qinhuai District CDC hosted a volunteer social welfare organizations compass studio, R & D Center for start-up companies, in college students. Second university student micro letter applet application development contest the national prize of the first projects, micro-channel applets "about the car you", "Hing charity", "Feng Yun-speed inspection" project chief engineer.