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


PHP Cookie::setCookie方法代码示例

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


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

示例1: AddComment

 private function AddComment(sfWebRequest $request)
 {
     $text = $request->getParameter('comment_text');
     if ($request->isMethod("GET")) {
         $text = urldecode($text);
     }
     if ($this->getRequestParameter('comment_picture_url')) {
         $filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url'));
         if ($text) {
             $text .= "<br/>";
         }
         $text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />";
     }
     if (!trim($text)) {
         return;
     }
     sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url'));
     $user = $this->getUser()->getGuardUser();
     $comment = new PostComment();
     $comment->setUser($user);
     $comment->setPost($this->post);
     if ($this->parent) {
         $comment->setParent($this->parent);
     }
     $comment->setComment(parsetext($text));
     $comment->setCommentOriginal($text);
     $comment->save();
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser) {
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
     }
 }
开发者ID:auphau,项目名称:joyreactor,代码行数:33,代码来源:actions.class.php

示例2: setCookie

 /**
  * @param $key
  * @param $value
  * @return $this
  */
 public function setCookie($key, $value)
 {
     if (!$this->cookie) {
         $this->cookie = new Cookie();
     }
     $this->cookie->setCookie($key, $value);
     return $this;
 }
开发者ID:nk2ge5k,项目名称:http,代码行数:13,代码来源:Request.php

示例3: parseNojs

 /**
  * 变脸项目-根据浏览器是否开启了js来展现不同的页面
  * @return boolean
  */
 public static function parseNojs(&$arrData)
 {
     $arrData['uiData']['queryInfo']['noscript'] = intval($_GET['nojs']);
     $arrData['uiData']['queryInfo']['cookieNoscript'] = intval($_COOKIE['NOJS']);
     if ($arrData['uiData']['queryInfo']['noscript'] == 1 && $arrData['uiData']['queryInfo']['cookieNoscript'] != 1) {
         Cookie::setCookie('NOJS', '1');
     }
 }
开发者ID:drehere,项目名称:shenmegui,代码行数:12,代码来源:ParamParser.php

示例4: register

 /**
  *
  * function: register
  * Register a new user
  * @access public
  * @param string $username
  * @param string $password
  * @param boolean $sticky (optional)
  * @return [boolean,User]
  */
 public function register($username, $password, $info = false)
 {
     $sql = 'INSERT INTO ' . $this->table . ' (username,password) VALUES (?,?);';
     $userId = $this->insert($sql, array($username, $this->bcrypt->hash(md5($password))));
     if (empty($userId)) {
         return false;
     } else {
         if (!empty($info)) {
             Users::updateUser($info, $userId);
         }
         Session::setUser($userId);
         if (!empty($sticky)) {
             Cookie::setCookie('user', $userId);
         }
         return $userId;
     }
 }
开发者ID:healeyb,项目名称:Helium,代码行数:27,代码来源:Users.php

示例5: clearCookie

 /**
  * Expire the rememberme cookie, unset $_COOKIE[$this->cookieName] value and
  * remove current login triplet from storage.
  * @param boolean $clearFromStorage
  * @return boolean
  */
 public function clearCookie($clearFromStorage = true)
 {
     if (empty($_COOKIE[$this->cookieName])) {
         return false;
     }
     $cookieValues = explode("|", $_COOKIE[$this->cookieName], 3);
     $this->cookie->setCookie($this->cookieName, "", time() - $this->expireTime);
     unset($_COOKIE[$this->cookieName]);
     if (!$clearFromStorage) {
         return true;
     }
     if (count($cookieValues) < 3) {
         return false;
     }
     $this->storage->cleanTriplet($cookieValues[0], $cookieValues[2] . $this->salt);
     return true;
 }
开发者ID:clee03,项目名称:metal,代码行数:23,代码来源:Authenticator.php

示例6: actions

 function actions()
 {
     if (array_key_exists('writeLocalLog', $this->parameters)) {
         Log::writeLocalLog();
     }
     if (array_key_exists('deletePhpErrorLog', $this->parameters)) {
         Log::deletePhpErrorLog();
     }
     if (array_key_exists('deleteLocalLog', $this->parameters)) {
         Log::deleteLocalLog();
     }
     if (array_key_exists('addCookie', $this->parameters)) {
         Cookie::setCookie();
     }
     if (array_key_exists('deleteAllCookies', $this->parameters)) {
         Cookie::deleteAllCookies();
     }
 }
开发者ID:evansteiner,项目名称:Mutt-PHP,代码行数:18,代码来源:FrameworkActionsController.php

示例7: login

 public function login()
 {
     if (isset($_POST['send'])) {
         parent::__construct($this->_tpl, new UserModel());
         $this->_model->user = $_POST['user'];
         $this->_model->pass = md5($_POST['pass']);
         if (!!($_user = $this->_model->checkLogin())) {
             $_cookie = new Cookie('user', $_user->user, $_POST['time']);
             $_cookie->setCookie();
             $_cookie = new Cookie('face', $_user->face, $_POST['time']);
             $_cookie->setCookie();
             $this->_model->id = $_user->id;
             $this->_model->time = time();
             $this->_model->setLaterUser();
             Tool::alertLocation(null, './');
         } else {
             Tool::alertBack('wrong username or password');
         }
     }
     $this->_tpl->assign('login', true);
 }
开发者ID:e0zhao02,项目名称:sample_code,代码行数:21,代码来源:RegisterAction.class.php

示例8: link_to_function

	<?php 
    echo link_to_function(__('Написать комментарий'), '$j(".addcomment").hide("fast");if($j("#addcomment' . $post->getId() . '").is(":visible"))$j("#addcomment' . $post->getId() . '").hide("fast"); else $j("#addcomment' . $post->getId() . '").show("fast")');
    ?>
</div>
<div id='addcomment<?php 
    echo $post->getId();
    ?>
' <?php 
    if (isset($showAddComment) && $showAddComment) {
        ?>
class='addcommentInline'<?php 
    } else {
        ?>
class='addcomment'<?php 
    }
    ?>
>
	<?php 
    include_partial('post_comment/addComment', array('post' => $post));
    ?>
</div>
<?php 
} else {
    ?>
    <?php 
    echo __('Только зарегистрированные пользователи могут добавлять комментарии.');
}
if ($sf_user->isAuthenticated()) {
    Cookie::setCookie($sf_user->getGuardUser(), "comments" . $post->getId(), $post->getAllComments('count'), time() + 24 * 60 * 60);
    Cookie::setCookie($sf_user->getGuardUser(), "comments" . $post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
}
开发者ID:auphau,项目名称:joyreactor,代码行数:31,代码来源:_post_comments.php

示例9: login

 public function login()
 {
     if (isset($_POST['send'])) {
         parent::__construct($this->_tpl, new UserModel());
         if (Validate::checkNull($_POST['user'])) {
             Tool::alertBack('警告:用户名不得为空!');
         }
         if (Validate::checkLength($_POST['user'], 2, 'min')) {
             Tool::alertBack('警告:用户名长度不得小于两位!');
         }
         if (Validate::checkLength($_POST['user'], 20, 'max')) {
             Tool::alertBack('警告:用户名长度不得大于二十位!');
         }
         if (Validate::checkLength($_POST['pass'], 6, 'min')) {
             Tool::alertBack('警告:密码不得小于六位!');
         }
         if (Validate::checkLength($_POST['code'], 4, 'equals')) {
             Tool::alertBack('警告:验证码必须是四位!');
         }
         if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
             Tool::alertBack('警告:验证码不正确!');
         }
         $this->_model->user = $_POST['user'];
         $this->_model->pass = sha1($_POST['pass']);
         if (!!($_user = $this->_model->checkLogin())) {
             $_cookie = new Cookie('user', $_user->user, $_POST['time']);
             $_cookie->setCookie();
             $_cookie = new Cookie('face', $_user->face, $_POST['time']);
             $_cookie->setCookie();
             $this->_model->id = $_user->id;
             $this->_model->time = time();
             $this->_model->setLaterUser();
             Tool::alertLocation(null, './');
         } else {
             Tool::alertBack('警告:用户名或密码错误!');
         }
     }
     $this->_tpl->assign('login', true);
 }
开发者ID:denson7,项目名称:phpstudy,代码行数:39,代码来源:RegisterAction.class.php

示例10: executePersonal

 public function executePersonal(sfWebRequest $request)
 {
     sfApplicationConfiguration::getActive()->loadHelpers(array('I18N', 'Parse'));
     $this->user = sfGuardUser::getUserByUsername($request->getParameter('username'));
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser && $this->user) {
         Cookie::setCookie($this->curUser, "personal" . $this->user->getId(), $this->user->getPersonalLine('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "personal" . $this->user->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
     }
     $this->forward404Unless($this->user);
     $this->getResponse()->setTitle("Лента / " . $this->user->getUsername() . " / " . __("JoyReactor – твое хорошее настроние. Картинки, приколы, видео, демотиваторы."));
 }
开发者ID:auphau,项目名称:joyreactor,代码行数:12,代码来源:actions.class.php


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