Home > Backend Development > PHP Tutorial > PHP的session使用

PHP的session使用

WBOY
Release: 2016-06-23 14:33:10
Original
753 people have browsed it

会话管理,非常重要的一部分,让参数在页面间来回传递,这是个简单的例子,边学边用,效果如图:

主页面index.php代码:

php
session_start ();
$_SESSION [ ' name ' ] = " zhang3 " ;
echo   " 通过SESSION传递用户zhang3,显示欢迎信息 " ;
?>

session_start ()开始会话,要使用session,每个页面必须调用。
page2.php代码:

php
session_start ();
echo   $_SESSION [ " name " ] . "  欢迎你! " . " 返回 " ;
?>


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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template