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


PHP Slim::setCookie方法代码示例

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


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

示例1: write

 /**
  * Writes $contents to storage
  *
  * @param  mixed                       $contents
  * @throws Zend_Auth_Storage_Exception If writing $contents to
  *                                     storage is impossible
  * @return void
  */
 public function write($contents)
 {
     if (isset($contents['password_hash'])) {
         unset($contents['password_hash']);
     }
     $value = json_encode($contents);
     $this->app->setCookie($this->cookieName, $value, $this->time);
 }
开发者ID:neophyt3,项目名称:flaming-archer,代码行数:16,代码来源:EncryptedCookie.php

示例2: function

};
$app->post('/login', function () use($app) {
    try {
        // get user and pass from post if from form as dataType=html
        //$username = $app->request->post('username');
        //$password = $app->request->post('password');
        // get user and pass from post - get and decode JSON request body
        $body = $app->request()->getBody();
        $input = json_decode($body);
        $username = (string) $input->username;
        $password = (string) $input->password;
        // this is how you can check what has been passed. Look into responds from ajaxPost.php
        //var_dump($password);
        if (isValidLogin($username, $password)) {
            // if username and pass are valid set Cookie
            $app->setCookie('username', $username, '1 day');
            $app->setCookie('password', $password, '1 day');
            $app->response()->header('Content-Type', 'application/json');
            $app->response()->status(200);
            // OK
            echo json_encode(array('operation' => 'login', 'status' => 'ok'));
        } else {
            throw new AuthenticateFailedException();
        }
    } catch (AuthenticateFailedException $e) {
        $app->response()->status(401);
        $app->response()->header('X-Status-Reason', 'Login failure');
    } catch (Exception $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
开发者ID:gsokolowski,项目名称:Php-REST-Slim-RedBean-authentication,代码行数:31,代码来源:index.php

示例3: function

**/
$app->get('/', function () use($app, $dl) {
    $app->render('home.twig', array('code' => $app->getCookie('code'), 'email' => $app->getCookie('email'), 'album' => $app->getCookie('album'), 'subscribe' => $app->getCookie('subscribe'), 'albums' => $dl->get_albums()));
})->name('home');
/**
* HOME ROUTE POST HANDELING
**/
$app->post('/', function () use($app, $dl, $mail) {
    // setup variables from the incoming post
    $album = $app->request->post('album');
    $email = $app->request->post('email');
    $code = strtoupper($app->request->post('code'));
    $subscribe = $app->request->post('mailing_list');
    $address = $app->request->post('address');
    // Set current entries to cookies
    $app->setCookie('code', $code);
    $app->setCookie('email', $email);
    $app->setCookie('album', $album);
    $app->setCookie('subscribe', $subscribe);
    // Make sure the Honey Pot field is empty.
    if (!empty($address)) {
        $app->flash('error', 'Your form submission has an error.');
        // Push them back to the main screen with generic error message
        $app->redirect($app->urlFor('home'));
    } elseif (!empty($code) && !empty($email)) {
        // Clean up the form submissions
        $cleanCode = filter_var($code, FILTER_SANITIZE_STRING);
        $cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
        $cleanAlbum = filter_var($album, FILTER_SANITIZE_STRING);
        // validate the email format
        $validEmail = filter_var($cleanEmail, FILTER_VALIDATE_EMAIL);
开发者ID:nblakefriend,项目名称:download,代码行数:31,代码来源:index.php


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