Home  >  Article  >  php教程  >  初学:在PHP开发中如何使用Session?

初学:在PHP开发中如何使用Session?

WBOY
WBOYOriginal
2016-06-13 10:29:31791browse

如何使用Session ? 


//必须在使用前加上;
session_start(); 
?> 
//考虑我们有时候考虑是否写入session
if (isset($_POST[userid])){ 
//如果真的同意写入:
$_SESSION[userid] = $ccdot

}else{ 
//或者返回不能写入session

?> 


要清除的时候:

session_start(); 
unset($_SESSION[userid]); //OR : session_register(username); 

session_unregister()函数主要作用是注消当前的一个session变量。不过要注意的是,如果你用$HTTP_SESSION_VARS或$_SESSION在当前页面
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