【发布时间】:2012-01-19 21:16:00
【问题描述】:
如果你能让这个简单的 SESSION VARIABLES 示例发挥作用,我会拥抱你!
我无法让会话变量在我的网站上运行。我正在使用 Chrome 浏览器在 Windows 7 上运行 php5。
这里是发送页面:
<?php
session_start();
$red='red';
$blue='blue';
$green='green';
$SESSVARS=array($red,$blue,$green);
$_SESSION['USERVARS']= $SESSVARS;
?>
<p>Set Sessionvars</p>
<form action="SessVarCheck.php" method="post">
<input name="Submit" type="submit">
</form>
这是结果页面:
<?php
session_start();
echo "val 1:".$_SESSION['USERVARS'][0];
echo "val 2:". $_SESSION['USERVARS'][1];
echo "val 3:". $_SESSION['USERVARS'][2];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SessVarCheck.php</title>
</head>
<body>
The Result page
</body>
</html>
我对所有三个回声都感到空虚。 欢迎任何想法!
【问题讨论】:
-
你在服务器上运行什么? (或者这都是本地的)
-
你试过 var_dump($_SESSION); 吗?
标签: php session session-variables