Home  >  Article  >  Backend Development  >  PHP Notes------About Session Operation

PHP Notes------About Session Operation

WBOY
WBOYOriginal
2016-08-08 09:27:411050browse

1. Determine whether the Session is assigned a value

if(!isset($_SESSION['username']) || $_SESSION['username']==''){
$this->redirect( 'Login/login');
}

2. Exit and clear the Session

$_SESSION=array();
if(isset($_COOKIE[session_name()])){
setcookie(session_name(),'',time()-1,'/');
}
session_destroy();
$this->redirect('Index/index');

The above introduces the PHP notes------About Session operation, including aspects of the content. 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