一个session很菜的问题

wingcn 2003-02-22 04:14:31
想用session记录数据在服务器端(以下代码),可是为什么重新刷新页面后,$count却不变的?本意是在刷新后$count自增1的,可为什么不能实现呢?代码出错了吗?在此请教各位,先谢谢了


<?
session_start();
session_register("count");
session_register("myname");
session_register("mylove");
$myname="abc";
$mylove="myself";
$count++;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>session</title>
</head>
<body>
count变量为:<? echo $count; ?><br>
我的ID为:<? echo session_id(); ?><br>
</body>
</html>
...全文
36 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
uGain 2003-02-22
  • 打赏
  • 举报
回复
<?
session_start();
$_SESSION['myname']="abc";
$_SESSION['mylove']="myself";
$_SESSION['count']++;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>session</title>
</head>
<body>
count变量为:<? echo $_SESSION['count']; ?><br>
我的ID为:<? echo session_id(); ?><br>
</body>
</html>


http://expert.csdn.net/Expert/TopicView1.asp?id=1312288

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧