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


PHP Cookie::getCookie方法代码示例

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


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

示例1: header

 public function header()
 {
     $_cookie = new Cookie('user');
     if ($_cookie->getCookie()) {
         echo "function getHeader() {\n\t\t\t\t\tdocument.write('{$_cookie->getCookie()},您好! <a href=\"register.php?action=logout\">退出</a> ');\n\t\t\t\t}";
     } else {
         echo "function getHeader() {\n\t\t\t\t\tdocument.write('<a href=\"register.php?action=reg\" class=\"user\">注册</a> <a href=\"register.php?action=login\" class=\"user\">登录</a>');\n\t\t\t\t}";
     }
 }
开发者ID:echo-tang,项目名称:XMFreamwork,代码行数:9,代码来源:Cache.class.php

示例2: header

 public function header()
 {
     $_cookie = new Cookie('user');
     if ($_cookie->getCookie()) {
         echo "function getHeader() {document.write('{$_cookie->getCookie()}, Hi! <a href=\"register.php?action=logout\">Logout</a>');}";
     } else {
         echo "function getHeader() {document.write('<a href=\"register.php?action=reg\" class=\"user\">Register</a><a href=\"register.php?action=login\" class=\"user\">Login</a>');}";
     }
 }
开发者ID:e0zhao02,项目名称:sample_code,代码行数:9,代码来源:Cache.class.php

示例3: validate

 public function validate()
 {
     $userIsValid = false;
     $cookieValue = Cookie::getCookie('login');
     // Methode aanspreken die instaat voor het verwerken van de cookie data
     // tot makkelijk bruikbare variabelen
     $processedCookieValue = $this->processCookieValue($cookieValue);
     if ($cookieValue && $processedCookieValue) {
         // Variabele aanmaken om leesbaarheid te bevorderen
         $email = $processedCookieValue['email'];
         $hashedSaltedEmailCookie = $processedCookieValue['hashedSaltedEmail'];
         // Salt ophalen uit database
         $salt = $this->getSalt($email);
         // Als de salt niet leeg is, is er een gebruiker teruggevonden met het emailadres
         // dat in de cookie staat
         if ($salt !== '') {
             // Creeer een zelfgemaakte hash op basis van het emailadres uit de cookie
             // en de salt uit de database
             $hashedSaltedEmailCheck = $this->hash($email, $salt);
             // Stemmen deze beide hashes (uit cookie & de zelfgemaakte) overeen
             // dan heeft de gebruiker een geldige cookie
             if ($hashedSaltedEmailCookie === $hashedSaltedEmailCheck) {
                 $userIsValid = true;
             }
         }
     }
     // Return of de gebruiker geldig is (TRUE//FALSE)
     return $userIsValid;
 }
开发者ID:EvaVanRumst,项目名称:Labo,代码行数:29,代码来源:User.php

示例4: addComment

 private function addComment()
 {
     if (isset($_POST['send'])) {
         $_url = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
         if ($_url == PREV_URL) {
             if (Validate::checkNull($_POST['content'])) {
                 Tool::alertBack('警告:评论内容不得为空!');
             }
             if (Validate::checkLength($_POST['content'], 255, 'max')) {
                 Tool::alertBack('警告:评论内容长度不得大于255位!');
             }
             if (Validate::checkLength($_POST['code'], 4, 'equals')) {
                 Tool::alertBack('警告:验证码必须是四位!');
             }
             if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
                 Tool::alertBack('警告:验证码不正确!');
             }
         } else {
             if (Validate::checkNull($_POST['content'])) {
                 Tool::alertClose('警告:评论内容不得为空!');
             }
             if (Validate::checkLength($_POST['content'], 255, 'max')) {
                 Tool::alertClose('警告:评论内容长度不得大于255位!');
             }
             if (Validate::checkLength($_POST['code'], 4, 'equals')) {
                 Tool::alertClose('警告:验证码必须是四位!');
             }
             if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
                 Tool::alertClose('警告:验证码不正确!');
             }
         }
         parent::__construct($this->_tpl, new CommentModel());
         $_cookie = new Cookie('user');
         if ($_cookie->getCookie()) {
             $this->_model->user = $_cookie->getCookie();
         } else {
             $this->_model->user = '游客';
         }
         $this->_model->manner = $_POST['manner'];
         $this->_model->content = $_POST['content'];
         $this->_model->cid = $_GET['cid'];
         $this->_model->addComment() ? Tool::alertLocation('评论添加成功,请等待管理员审核!', 'feedback.php?cid=' . $this->_model->cid) : Tool::alertLocation('评论添加失败,请重新添加!', 'feedback.php?cid=' . $this->_model->cid);
     }
 }
开发者ID:denson7,项目名称:phpstudy,代码行数:44,代码来源:FeedBackAction.class.php

示例5: addComment

 private function addComment()
 {
     if (isset($_POST['send'])) {
         $_url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
         if ($_url == PREV_URL) {
             if (Validate::checkNull($_POST['content'])) {
                 Tool::alertBack('content empty');
             }
             if (Validate::checkLength($_POST['content'], 255, 'max')) {
                 Tool::alertBack('content longer than 255');
             }
             if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
                 Tool::alertBack('validate code must match');
             }
         } else {
             if (Validate::checkNull($_POST['content'])) {
                 Tool::alertClose('content empty');
             }
             if (Validate::checkLength($_POST['content'], 255, 'max')) {
                 Tool::alertClose('content longer than 255');
             }
             if (Validate::checkEquals(strtolower($_POST['code']), $_SESSION['code'])) {
                 Tool::alertClose('validate code must match');
             }
         }
         parent::__construct($this->_tpl, new CommentModel());
         $_cookie = new Cookie('user');
         if ($_cookie->getCookie()) {
             $this->_model->user = $_cookie->getCookie();
         } else {
             $this->_model->user = 'Guest';
         }
         $this->_model->manner = $_POST['manner'];
         $this->_model->content = $_POST['content'];
         $this->_model->cid = $_GET['cid'];
         $this->_model->addComment() ? Tool::alertLocation('succeed', 'feedback.php?cid=' . $this->_model->cid) : Tool::alertLocation('failed', 'feedback.php?cid=' . $this->_model->cid);
     }
 }
开发者ID:e0zhao02,项目名称:sample_code,代码行数:38,代码来源:FeedBackAction.class.php

示例6: saveUser

 private function saveUser()
 {
     $email = $this->email;
     $login = $this->login;
     $password = md5($this->password);
     //hash
     $cookie = new Cookie();
     $cookieGet = $cookie->getCookie($this->app);
     $user = new User();
     $user->login = $login;
     $user->password = $password;
     $user->email = $email;
     $user->cookie = $cookieGet;
     $Usermapper = new UserMapper($this->db);
     $Usermapper->save($user);
     $this->app->redirect('/TwigBlog');
 }
开发者ID:toppestkek,项目名称:TwigBlog,代码行数:17,代码来源:Validator.php

示例7: sendRequest

 public function sendRequest($url, array $query_data = [], $cookie = true)
 {
     /**
      * @var \HttpQueryString $params
      */
     $queryData = new \http\QueryString($query_data);
     /**
      * @var \HttpRequest $http
      */
     $request = new \http\Client\Request("GET", $url);
     if (!empty($queryData)) {
         $request->getBody()->append($queryData);
     }
     $request->setContentType("application/x-www-form-urlencoded");
     $client = new \http\Client();
     $cookie_file = 'cookie.log';
     if ($cookie) {
         $cookie_str = file_exists($cookie_file) ? file_get_contents($cookie_file) : '';
         $cookie = new Cookie($cookie_str);
         $client_cookie = $cookie->getCookie('frontend');
         if ($client_cookie != 'deleted') {
             $client->addCookies(['frontend' => $client_cookie]);
         }
     }
     $client->enqueue($request);
     $client->send();
     /** @var \HttpResponse $response */
     $response = $client->getResponse($request);
     printf("Sent:\n%s\n\n", $response->getParentMessage());
     printf("%s returned '%s'\n%s\n", $response->getTransferInfo("effective_url"), $response->getInfo(), $response->getBody());
     file_put_contents($cookie_file, '');
     foreach ($response->getCookies() as $cookie) {
         /* @var $cookie http\Cookie */
         foreach ($cookie->getCookies() as $name => $value) {
             $cookie = new \http\Cookie();
             $cookie->addCookie($name, $value);
             file_put_contents($cookie_file, $cookie->toString(), FILE_APPEND);
         }
     }
     print_r($response->getHeaders());
     return json_decode($response->getBody(), true);
 }
开发者ID:nilyang,项目名称:thrift-laravel,代码行数:42,代码来源:CookieTest.php

示例8: login

 public function login()
 {
     $_cookie = new Cookie('user');
     $_user = $_cookie->getCookie();
     $_cookie = new Cookie('face');
     $_face = $_cookie->getCookie();
     if ($_user && $_face) {
         $this->_tpl->assign('user', Tool::subStr($_user, null, 8, null));
         $this->_tpl->assign('face', $_face);
     } else {
         $this->_tpl->assign('login', true);
     }
     $this->_tpl->assign('cache', IS_CACHE);
     if (IS_CACHE) {
         $this->_tpl->assign('member', '<script>getIndexLogin();</script>');
     }
 }
开发者ID:e0zhao02,项目名称:sample_code,代码行数:17,代码来源:IndexAction.class.php

示例9: function

    $app->render('Insert.php');
})->name('insert');
//->conditions(['id' => '[0-9]+'])
$app->post('/insert', function () use($app) {
    if (empty($_FILES['img']['tmp_name'])) {
        $app->redirect('insert');
    } elseif (!empty($_FILES['img']['tmp_name'])) {
        //getting file by $_POST
        $filepost = new FilePost();
        $generateToken = new Token();
        $array = $filepost->postFile($generateToken, $_POST, $_FILES);
        //var_dump($filepost->postFile($generateToken, $_POST, $_FILES));
        //var_dump($array);
        $cookiecheck = new Cookie();
        //setting cookie
        $cookie = $cookiecheck->getCookie($app);
        $db = $app->db;
        $user = new User();
        $usermapper = new UserMapper($db);
        $userid = new UserId();
        $user_id = $userid->checkId($user, $usermapper, $cookie);
        //saving file in DB
        $foo = new Foo();
        $regExp = new RegExp();
        $token = $regExp->match($array['token']);
        $foo->public = $regExp->match($array['public']);
        $foo->terminate = $array['terminate'];
        $foo->user_id = $regExp->match($user_id);
        $foo->path = $regExp->match($array['filename']);
        // $foo->cookie = $cookie;
        $foo->token = $regExp->match($token);
开发者ID:toppestkek,项目名称:TwigBlog,代码行数:31,代码来源:insert.php

示例10: NavAction

<?php

define('IS_CACHE', false);
global $_tpl, $_cache;
if (IS_CACHE && !$_cache->noCache()) {
    ob_start();
    $_tpl->cache(Tool::tplName() . '.tpl');
}
$_nav = new NavAction($_tpl);
$_nav->showfront();
$_cookie = new Cookie('user');
if (IS_CACHE) {
    $_tpl->assign('header', '<script>getHeader();</script>');
} else {
    if ($_cookie->getCookie()) {
        $_tpl->assign('header', 'Hello ' . $_cookie->getCookie() . ', <a href="register.php?action=logout">Logout</a>');
    } else {
        $_tpl->assign('header', '<a href="register.php?action=reg" class="user">Register</a> <a href="register.php?action=login" class="user">Login</a>');
    }
}
开发者ID:e0zhao02,项目名称:sample_code,代码行数:20,代码来源:common.inc.php

示例11: Cookie

    $cookieGet = new Cookie();
    $cookie = $cookieGet->getCookie($app);
    $logged = new Logged();
    $user_id = $logged->getLogged($db, $cookie);
    $login = new Login();
    $log = $login->getLogin($user_id, $db);
    if ($log != 'Anonymous') {
        $app->redirect('/TwigBlog');
    } else {
        $app->render('Enter.php');
    }
})->name('enter');
$app->post('/enter', function () use($app) {
    $db = $app->db;
    $cookieGet = new Cookie();
    $cookie = $cookieGet->getCookie($app);
    $logged = new Logged();
    $user_id = $logged->getLogged($db, $cookie);
    $login = new Login();
    $log = $login->getLogin($user_id, $db);
    if ($log != 'Anonymous') {
        $app->redirect("/TwigBlog");
    } else {
        /*
         $login=htmlspecialchars($_POST['login']);
         $password=htmlspecialchars($_POST['password']);
          //checking if user exists
        * 
        */
        $userpost = new UserPost();
        $postarr = $userpost->postEnter($_POST);
开发者ID:toppestkek,项目名称:TwigBlog,代码行数:31,代码来源:enter.php

示例12: NavAction

<?php

//前台缓存开关
define('IS_CAHCE', true);
//模板句柄
global $_tpl, $_cache;
if (IS_CAHCE && !$_cache->noCache()) {
    ob_start();
    $_tpl->cache(Tool::tplName() . '.tpl');
}
$_nav = new NavAction($_tpl);
$_nav->showfront();
//列出主导航
$_cookie = new Cookie('user');
if (IS_CAHCE) {
    $_tpl->assign('header', '<script type="text/javascript">getHeader();</script>');
} else {
    if ($_cookie->getCookie()) {
        $_tpl->assign('header', $_cookie->getCookie() . ',您好! <a href="register.php?action=logout">退出</a> ');
    } else {
        $_tpl->assign('header', '	<a href="register.php?action=reg" class="user">注册</a> <a href="register.php?action=login" class="user">登录</a>');
    }
}
$_link = new FriendLinkAction($_tpl);
$_link->index();
$_tag = new TagAction($_tpl);
$_tag->getFiveTag();
$_tpl->assign('webname', WEBNAME);
开发者ID:denson7,项目名称:phpstudy,代码行数:28,代码来源:common.inc.php

示例13: getCookie

 public function getCookie($name)
 {
     return Cookie::getCookie($this, $name);
 }
开发者ID:auphau,项目名称:joyreactor,代码行数:4,代码来源:sfGuardUser.class.php

示例14: login

 private function login()
 {
     $_cookie = new Cookie('user');
     $_user = $_cookie->getCookie();
     $_cookie = new Cookie('face');
     $_face = $_cookie->getCookie();
     if ($_user && $_face) {
         $this->_tpl->assign('user', Tool::subStr($_user, null, 8, 'utf-8'));
         $this->_tpl->assign('face', $_face);
     } else {
         $this->_tpl->assign('login', true);
     }
     $this->_tpl->assign('cache', IS_CAHCE);
     if (IS_CAHCE) {
         $this->_tpl->assign('member', '<script type="text/javascript">getIndexLogin();</script>');
     }
 }
开发者ID:denson7,项目名称:phpstudy,代码行数:17,代码来源:IndexAction.class.php

示例15: __construct

 protected function __construct()
 {
     //Initialize cookie object.
     $this->Cookie = Cookie::getCookie();
 }
开发者ID:serebrov,项目名称:so-questions,代码行数:5,代码来源:parent.php


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