当前位置: 首页>>代码示例>>PHP>>正文


PHP HeaderUtil::setCookie方法代码示例

本文整理汇总了PHP中HeaderUtil::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP HeaderUtil::setCookie方法的具体用法?PHP HeaderUtil::setCookie怎么用?PHP HeaderUtil::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HeaderUtil的用法示例。


在下文中一共展示了HeaderUtil::setCookie方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setLastVisitTime

 /**
  * Sets the global board last visit timestamp.
  */
 public function setLastVisitTime($timestamp)
 {
     $this->lastVisitTime = $timestamp;
     // cookie
     HeaderUtil::setCookie('boardLastVisitTime', $this->lastVisitTime, TIME_NOW + 365 * 24 * 3600);
     // session
     SessionFactory::getActiveSession()->register('boardLastVisitTime', $this->lastVisitTime);
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:11,代码来源:WBBGuestSession.class.php

示例2: doLogout

 /**
  * @see LogoutAction::doLogout()
  */
 protected function doLogout()
 {
     parent::doLogout();
     // remove cookies
     if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) {
         HeaderUtil::setCookie('userID', 0);
     }
     if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
         HeaderUtil::setCookie('password', '');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:14,代码来源:UserLogoutAction.class.php

示例3: handleCookie

 /**
  * Examines whether cookies are enabled.
  */
 protected function handleCookie()
 {
     if (isset($_COOKIE[COOKIE_PREFIX . 'cookieHash'])) {
         if ($_COOKIE[COOKIE_PREFIX . 'cookieHash'] != $this->sessionID) {
             $this->useCookies = false;
         }
     } else {
         $this->useCookies = false;
     }
     if (!$this->useCookies) {
         HeaderUtil::setCookie('cookieHash', $this->sessionID);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:16,代码来源:CookieSession.class.php

示例4: loginAutomatically

 /**
  * @see UserAuth::loginAutomatically()
  */
 public function loginAutomatically($persistent = false, $userClassname = 'UserSession')
 {
     if (!$persistent) {
         return null;
     }
     $user = null;
     if (isset($_COOKIE[COOKIE_PREFIX . 'userID']) && isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
         if (!($user = $this->getUserAutomatically(intval($_COOKIE[COOKIE_PREFIX . 'userID']), $_COOKIE[COOKIE_PREFIX . 'password'], $userClassname))) {
             $user = null;
             // reset cookie
             HeaderUtil::setCookie('userID', '');
             HeaderUtil::setCookie('password', '');
         }
     }
     return $user;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:19,代码来源:UserAuthDefault.class.php

示例5: init

 /**
  * Initialises the session.
  */
 public function init()
 {
     parent::init();
     // handle style id
     if ($this->user->userID) {
         $this->styleID = $this->user->styleID;
     }
     if (($styleID = $this->getVar('styleID')) !== null) {
         $this->styleID = $styleID;
     }
     if ($this->userID) {
         // user
         // update board / thread visits
         if ($this->user->boardLastActivityTime > $this->user->boardLastVisitTime && $this->user->boardLastActivityTime < TIME_NOW - SESSION_TIMEOUT) {
             $this->user->setLastVisitTime($this->user->boardLastActivityTime);
             // remove unnecessary board and thread visits
             $sql = "DELETE FROM\twbb" . WBB_N . "_thread_visit\n\t\t\t\t\tWHERE\t\tuserID = " . $this->userID . "\n\t\t\t\t\t\t\tAND lastVisitTime <= " . $this->user->boardLastMarkAllAsReadTime;
             WCF::getDB()->registerShutdownUpdate($sql);
             $sql = "DELETE FROM\twbb" . WBB_N . "_board_visit\n\t\t\t\t\tWHERE\t\tuserID = " . $this->userID . "\n\t\t\t\t\t\t\tAND lastVisitTime <= " . $this->user->boardLastMarkAllAsReadTime;
             WCF::getDB()->registerShutdownUpdate($sql);
             // reset user data
             $this->resetUserData();
         }
         // update global last activity time
         if ($this->lastActivityTime < TIME_NOW - USER_ONLINE_TIMEOUT + 299) {
             WBBUserSession::updateLastActivityTime($this->userID);
         }
     } else {
         // guest
         $boardLastActivityTime = 0;
         $boardLastVisitTime = $this->user->getLastVisitTime();
         if (isset($_COOKIE[COOKIE_PREFIX . 'boardLastActivityTime'])) {
             $boardLastActivityTime = intval($_COOKIE[COOKIE_PREFIX . 'boardLastActivityTime']);
         }
         if ($boardLastActivityTime != 0 && $boardLastActivityTime < $boardLastVisitTime && $boardLastActivityTime < TIME_NOW - SESSION_TIMEOUT) {
             $this->user->setLastVisitTime($boardLastActivityTime);
             $this->resetUserData();
         }
         HeaderUtil::setCookie('boardLastActivityTime', TIME_NOW, TIME_NOW + 365 * 24 * 3600);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:44,代码来源:WBBSession.class.php

示例6: save

 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // get user editor
     $editor = WCF::getUser()->getEditor();
     $success = array();
     // quit
     if (WCF::getUser()->getPermission('user.profile.canQuit')) {
         if (!WCF::getUser()->quitStarted && $this->quit == 1) {
             $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
             WCF::getDB()->sendQuery($sql);
             $this->quitStarted = TIME_NOW;
             $success[] = 'wcf.user.quit.success';
         } else {
             if (WCF::getUser()->quitStarted && $this->cancelQuit == 1) {
                 $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = 0\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
                 WCF::getDB()->sendQuery($sql);
                 $this->quitStarted = 0;
                 $success[] = 'wcf.user.quit.cancel.success';
             }
         }
     }
     // username
     if ($this->canChangeUsername && $this->username != WCF::getUser()->username) {
         $fields = array();
         if (StringUtil::toLowerCase($this->username) != StringUtil::toLowerCase(WCF::getUser()->username)) {
             if (!$this->canChangeUsername) {
                 $this->username = WCF::getUser()->username;
                 return;
             }
             $fields = array('lastUsernameChange' => TIME_NOW, 'oldUsername' => $editor->username);
         }
         $editor->update($this->username, '', '', null, null, $fields);
         $success[] = 'wcf.user.rename.success';
     }
     // email
     if (WCF::getUser()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) {
         if (REGISTER_ACTIVATION_METHOD == 0 || REGISTER_ACTIVATION_METHOD == 2 || StringUtil::toLowerCase($this->email) == StringUtil::toLowerCase(WCF::getUser()->email)) {
             // update email
             $editor->update('', $this->email);
             $success[] = 'wcf.user.emailChange.success';
         } else {
             if (REGISTER_ACTIVATION_METHOD == 1) {
                 // get reactivation code
                 $activationCode = UserRegistrationUtil::getActivationCode();
                 // save as new email
                 $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\treactivationCode = " . $activationCode . ",\n\t\t\t\t\t\tnewEmail = '" . escapeString($this->email) . "'\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
                 WCF::getDB()->registerShutdownUpdate($sql);
                 $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE));
                 $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => WCF::getUser()->username, '$userID' => WCF::getUser()->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS);
                 require_once WCF_DIR . 'lib/data/mail/Mail.class.php';
                 $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail', $messageData));
                 $mail->send();
                 $success[] = 'wcf.user.emailChange.needReactivation';
             }
         }
     }
     // password
     if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) {
         $editor->update('', '', $this->newPassword);
         // update cookie
         if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
             HeaderUtil::setCookie('password', StringUtil::getSaltedHash($this->newPassword, $editor->salt), TIME_NOW + 365 * 24 * 3600);
         }
         $success[] = 'wcf.user.passwordChange.success';
     }
     // reset session
     WCF::getSession()->resetUserData();
     $this->saved();
     // show success message
     WCF::getTPL()->assign('success', $success);
     // reset password
     $this->password = '';
     $this->newPassword = $this->confirmNewPassword = '';
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:78,代码来源:AccountManagementForm.class.php

示例7: logout

    public static function logout($newSite = false)
    {
        global $game_config;
        require_once WCF_DIR . 'lib/system/session/UserSession.class.php';
        WCF::getSession()->changeUser(new UserSession());
        // remove cookies
        if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) {
            HeaderUtil::setCookie('userID', 0);
        }
        if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
            HeaderUtil::setCookie('password', '');
        }
        setcookie($game_config['COOKIE_NAME'], "", time() - 100000, "/", "", 0);
        if ($newSite === false) {
            return;
        }
        echo '<html>
				<head>
					<script language="JavaScript" >
						top.location.href = \'' . $newSite . '?time=' . TIME_NOW . '\';
					</script>
				</head>
				<body>
					<center>
						<a href="javascript:top.location.href=\'' . $newSite . '?time=' . TIME_NOW . '\'">
							Du wurdest ausgeloggt. Hier klicken, um wieder auf die Startseite zu kommen.
						</a>
					</center>
				</body>
			  </html>';
        exit;
    }
开发者ID:sonicmaster,项目名称:RPG,代码行数:32,代码来源:LWCore.class.php


注:本文中的HeaderUtil::setCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。