网站学习备忘006——Session,页面计数器

网站学习备忘006——Session,页面计数器_第1张图片



<html>
	<head>
		<title>Session,页面计数器</title>
	</head>
	<body>
		<?php
			//创建session变量,开始一个会话
			session_start();
			session_register('counter');
			
			$counter = $_SESSION['counter']+1;
			$_SESSION['counter'] = $counter;
			echo "第".$_SESSION['counter']."访问本页面!";
		?>
	</body>
</html>




删除会话


网站学习备忘006——Session,页面计数器_第2张图片


<html>
	<head>
		<title>删除Session</title>
	</head>
	<body>
		<?php
			if(isset($PHPSESSID))
			{
				$message = "<p/>End of session ($PHPSESSID).";
				session_start();
				session_destroy();
			}
			else
			{
				$message = "<p/>There was no session to destroy!";
			}
			
			echo $message;
		?>
	</body>
</html>


你可能感兴趣的:(网站学习备忘006——Session,页面计数器)