日期:2014-05-17 浏览次数:20725 次
<?php class CookieManager{ public function Get_CookieV($key){ //获取cookie return $_COOKIE[$key]; } public function Set_Array_Cookie($arryc){ //获取的cookie数组循环 foreach($arryc as $key=>$value){ setcookie($key,$value); } } public function Set_Cookie($key,$value){ //设定 setcookie($key,$value); } public function Get_Array_Cookie(){ return $_COOKIE; } public function up_Cookie($key,$value){ setcookie($key,"",$time); } } global $cm; if(!isset($cm)){ $cm=new CookieManager(); //判断是否存在$cm变量,不存在则实例化 } ?>
<?php ob_start(); require_once('inc/cookiemanager.php'); $cm=new CookieManager(); if(!$cm->Get_CookieV("username")){ echo <<<EOT <form id="form1" name="form1" method="POST" action="login.php"> <label>username: <input type="text" name="username" /> </label> <p>password: <label> <input type="text" name="password" /> </label> </p> <p> <label> <input type="submit" name="ButtonNname" value="登录" /> </label> </p> <p> </p> EOT; } else{ print_r($cm->Get_Array_Cookie()); echo '<p><a href="loginend.php?out=true">退出</a>'; } ob_flush(); ?>
<?php class CookieManager{ public function Get_CookieV($key){ //获取cookie return $_COOKIE[$key]; } public function Set_Array_Cookie($arryc){ //获取的cookie数组循环 foreach($arryc as $key=>$value){ setcookie($key,$value); } } public function Set_Cookie($key,$value){ //设定 setcookie($key,$value); } public function Get_Array_Cookie(){ return $_COOKIE; } public function up_Cookie($key,$value){ setcookie($key,"",$time); } } ?>