Home > Backend Development > PHP Tutorial > 关于session解决思路

关于session解决思路

WBOY
Release: 2016-06-13 11:13:11
Original
1021 people have browsed it

关于session
我有两个文件page1.php  and  page2.php
想在page1.php中实现将用户输入的姓名传递到page2.php中但是怎么也无法将session变量的值传过去
page1.php:

Session_start();
if(isset($_POST['Submit']))
{
$_SESSION['myname']=$_POST['name'];
}
?>
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



无标题文档




请输入你的姓名:













page2.php:
session_start();
//echo $_SESSION["myname"];
print_r($_SESSION);
?>
session
------解决方案--------------------
可能你好多概念都没弄清楚:
客户端和服务器端的关系
输入数据(客户端)->提交->读取_POST(服务器端)/session赋值(服务器端)
page1->提交->page2

page1的session start时,客户端还没有输入数据,何来_POST呢?
到提交后就跳到page2了,已经过了page1这个村了,哪有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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template