當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cookie::clear方法代碼示例

本文整理匯總了PHP中Cookie::clear方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cookie::clear方法的具體用法?PHP Cookie::clear怎麽用?PHP Cookie::clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cookie的用法示例。


在下文中一共展示了Cookie::clear方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loginout

 function loginout()
 {
     foreach ($_COOKIE as $key => $value) {
         Cookie::delete($key);
         Cookie::clear();
     }
     $this->redirect('Index');
 }
開發者ID:xuping123,項目名稱:kshop,代碼行數:8,代碼來源:LoginAction.class.php

示例2: checkLogin

 public function checkLogin()
 {
     //Cookie::delete("userinfo");
     //  		session_unset();
     // 		session_destroy();
     // 		exit;
     $userinfo = Cookie::get("userinfo");
     $userinfo["user"] ? $_POST["account"] = $userinfo["user"] : ($_POST["account"] = $_REQUEST["account"]);
     $userinfo['pwd'] ? $_POST["password"] = $userinfo['pwd'] : ($_POST["password"] = $_REQUEST["password"]);
     //$_POST["password"]="567";
     if ($_POST["account"] && $_POST["password"]) {
         //先判讀cookie裏存的userinfo,再判斷通過REQUEST傳遞過來的數據
         if ($_SESSION[C('USER_AUTH_KEY')]) {
             //不管安全問題隻管性能,如果存在,直接判斷有就繞開判斷,以後可以用握手協議來記錄安全
             // 				$map=array();
             // 				$map['account']	= $userinfo['user'];
             // 				$map['password']= $userinfo['pwd'];
             // 				$map["status"]	=array('gt',0);
             // 				$authInfo =RBAC::authenticate($map);
             // 				if($authInfo){
             // 					return true;
             // 				}
             //延長cookie超時時間
             Cookie::set("userinfo", Cookie::get("userinfo"), C('COOKIE_EXPIRE'));
             //驗證完成後清理
             unset($_POST["account"]);
             unset($_POST["password"]);
             return true;
         } else {
             $authInfo = $this->getAuthInfo();
             if ($authInfo) {
                 //--------------此部分為驗證密碼-------------------//
                 $this->loginType = "checkLogin";
                 //核驗類型為:檢驗登錄
                 $this->checkPwd($authInfo);
                 $this->setSession($authInfo);
                 //重新設置session
                 $this->setUserInfoCookie($authInfo);
                 //設置UserInfo的cookie
                 //驗證完成後清理
                 unset($_POST["account"]);
                 unset($_POST["password"]);
                 return true;
             } else {
                 //更新online信息,類型為刪除
                 $this->setUserOnline($authInfo = "logout", $type = "delete");
                 // 		session_unset();
                 // 		session_destroy();
                 //銷毀cookie
                 Cookie::delete("userinfo");
                 Cookie::clear();
                 return false;
             }
         }
     } else {
         //更新online信息,類型為刪除
         $this->setUserOnline($authInfo = "logout", $type = "delete");
         // 		session_unset();
         // 		session_destroy();
         //銷毀cookie
         Cookie::delete("userinfo");
         Cookie::clear();
         return false;
     }
 }
開發者ID:tmlsoft,項目名稱:main,代碼行數:65,代碼來源:PublicAction.class.php

示例3: logout

 public function logout()
 {
     Session::clear();
     Cookie::delete("email");
     Cookie::delete("password");
     Cookie::clear();
     $this->redirect("index", "Index");
 }
開發者ID:skiman100,項目名稱:thinksns,代碼行數:8,代碼來源:PublicAction.class.php

示例4: todoDBInit

 /**
  * @Title: todoDBInit
  * @Description: todo(清除數據表數據)
  * @author jiangx
  * @throws
  */
 public function todoDBInit()
 {
     //獲取當前數據庫的所有表名
     $database = C('DB_NAME');
     $model = M("INFORMATION_SCHEMA.TABLES", '', '', 1);
     $map['_string'] = " TABLE_SCHEMA = '" . $database . "'";
     $tableslist = $model->where($map)->field($field)->getfield('TABLE_NAME,TABLE_COMMENT');
     //不會被清空的數據表
     $tables = $this->tablelist;
     foreach ($_REQUEST['tables'] as $val) {
         $tables[$val] = $val;
     }
     foreach ($tableslist as $key => $val) {
         if ($tables[$key]) {
             continue;
         }
         $tablemodel = M($key);
         $sql = "DELETE FROM `" . $key . "`";
         $result = $tablemodel->execute($sql);
         if ($result === false) {
             $this->error(L('_ERROR_'));
         }
     }
     //初始化一個admin賬號 姓名admin 密碼 admin
     if (!isset($tableslist['user'])) {
         $this->error(L('數據庫沒有user數據表,不能初始化admin用戶'));
     }
     $usermodel = M("user");
     $map = array();
     $map['account'] = 'admin';
     $adminuser = $usermodel->where($map)->find();
     if (!$adminuser) {
         $_POST['account'] = 'admin';
         $_POST['name'] = 'admin';
         $_POST['password'] = md5('admin');
         unset($_POST['tables']);
         if (false === $usermodel->create()) {
             $this->error($usermodel->getError());
         }
         $list = $usermodel->add();
         if ($list === false) {
             $this->error(L('初始化user用戶失敗'));
         }
     }
     $this->transaction_model->commit();
     //事務提交
     if ($adminuser) {
         //注銷登錄
         $data = array();
         //$data['last_login_time'] ="";
         $data['isonline'] = 0;
         $data['sessionid'] = "";
         $data['leavetime'] = time();
         $data['id'] = $_SESSION[C('USER_AUTH_KEY')];
         $usermodel->save($data);
         $usermodel->commit();
     }
     unset($_SESSION);
     Cookie::delete("userinfo");
     Cookie::clear();
     session_destroy();
     $this->success('清空數據表成功!');
     $this->redirect('/Public/login/');
 }
開發者ID:tmlsoft,項目名稱:main,代碼行數:70,代碼來源:MisSystemDBInitializationAction.class.php

示例5: die

<?php

Page::ignore_view();
if ('renew' == Request::get(1)) {
    die('11');
    Session::clear();
    Cookie::clear();
}
$m = new SampleModel();
if ($m->try_post()) {
    if ($m->pwd == Conf::$management_center_password) {
        Auth::im_admin('YYUC_sys');
        Redirect::to('index');
    } else {
        Session::once('logerr', '登錄失敗!');
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>YYUC開發管理中心</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script type="text/javascript">var yyuc_jspath = "/@system/";</script>
		<script type="text/javascript" src="/@system/js/jquery.js"></script>
		<script type="text/javascript" src="/@system/js/yyucadapter.js"></script>
		<!-- stylesheets -->
		<link rel="stylesheet" type="text/css" href="/@system/mg/reset.css" />
		<link rel="stylesheet" type="text/css" href="/@system/mg/style.css" media="screen" />
		<link id="color" rel="stylesheet" type="text/css" href="/@system/mg/colors/blue.css" />
		<style>
開發者ID:codingoneapp,項目名稱:codingone,代碼行數:31,代碼來源:login.php

示例6: checkLogin

 public function checkLogin()
 {
     $account = $_REQUEST["account"];
     $pwd = $_REQUEST["password"];
     $userinfo = Cookie::get("userinfo");
     if ($account && $pwd || $userinfo["user"] && $userinfo['pwd']) {
         if ($account && $pwd) {
             $map = array();
             $map['account'] = $account;
             $map['password'] = $pwd;
         } else {
             $map = array();
             $map['account'] = $userinfo['user'];
             $map['password'] = $userinfo['pwd'];
         }
         $map["status"] = array('gt', 0);
         $authInfo = RBAC::authenticate($map);
         if ($authInfo) {
             //cookie驗證重新賦值
             if (ACTION_NAME != "getAllScheduleList") {
                 $this->setBBSCookie($authInfo);
                 $this->setUserInfoCookie($authInfo);
             }
             if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
                 $this->setSession($authInfo);
                 //更新user_online表
                 $online_model = M("user_online");
                 $onlinedata = array();
                 $onlinedata["modify_time"] = time();
                 $onlinedata["session_id"] = session_id();
                 $online_model->where("userid=" . $authInfo['id'])->save($onlinedata);
             }
             // 緩存訪問權限
             RBAC::saveAccessList();
             $same_time_login = intval(getCommonSettingSkey("SAME_TIME_LOGIN"));
             if (ACTION_NAME != "getAllScheduleList") {
                 $modeluseronline = D("UserOnline");
                 $aMap = array();
                 $aMap['userid'] = $authInfo["id"];
                 $info = $modeluseronline->where($aMap)->find();
                 $time = time();
                 $session_id = session_id();
                 if ($info) {
                     //存在,則檢查session_id
                     if ($same_time_login == 0) {
                         if ($info['session_id'] == $session_id) {
                             //修改時間
                             $modeluseronline->where($aMap)->setField('modify_time', $time);
                         } else {
                             $this->assign("jumpUrl", __APP__ . '/Public/login/');
                             unset($_SESSION);
                             Cookie::delete("userinfo");
                             Cookie::delete("bbsuserinfo");
                             Cookie::clear();
                             session_destroy();
                             $this->error("已在其他地方登陸,被迫下線", '', '', '301');
                             exit;
                         }
                     } else {
                         $modeluseronline->where($aMap)->setField('modify_time', $time);
                     }
                 } else {
                     //如果不存在userid,插入
                     $data = array();
                     $data = array('userid' => $authInfo["id"], 'session_id' => $session_id, 'modify_time' => $time, 'createid' => $authInfo["id"], 'createtime' => $time);
                     $modeluseronline->add($data);
                 }
             }
             return true;
         }
     } else {
         //提示請求時返回json數據
         if (ACTION_NAME == "getAllScheduleList") {
             $rehtml["html"] = 0;
             $rehtml['date'] = "";
             $rehtml['datalist'] = 0;
             echo json_encode($rehtml);
             exit;
         }
     }
     unset($_SESSION);
     Cookie::delete("userinfo");
     Cookie::delete("bbsuserinfo");
     Cookie::clear();
     session_destroy();
     return false;
 }
開發者ID:tmlsoft,項目名稱:main,代碼行數:87,代碼來源:PublicbackupAction.class.php


注:本文中的Cookie::clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。