Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 10:29:31
Original
784 people have browsed it

如何使用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在当前页面
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!