php处理cookie

      脚本天地 2005-6-23 11:57
<?php
	get_variable("set");
	get_variable("name");
	
	if ($set) {
	  setcookie("mycookie",$name);
	  header("Location: cookie.php");
	  exit;
	}

	
function get_variable($variable_name) {
	global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $variable_name;
	$variable_name = "";
	//GPC order :)
	if (isset($HTTP_GET_VARS[$variable_name])) $variable_name = $HTTP_GET_VARS[$variable_name];
	if (isset($HTTP_POST_VARS[$variable_name])) $variable_name = $HTTP_POST_VARS[$variable_name];
	if (is_string($variable_name)) {
		$variable_name = str_replace("\0","", $variable_name);
		$variable_name = str_replace("\t"," ", $variable_name);
		if (get_magic_quotes_gpc()) $variable_name = stripslashes($variable_name);
	}
}
?>
<html>
<head>
  <title>haha</title>
</head>
<body>

<?php echo "Now is ".count($HTTP_COOKIE_VARS)."<br>";?>
<form  action="cookie.php"  method="POST">
name <input type="text" name="name" size="20"><br>
<input type="submit" value="Set" name="set">
</form> 
</body>	
</html>
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}