kecik/cookie 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kecik/cookie

最新稳定版本:1.0.2

Composer 安装命令:

composer require kecik/cookie

包简介

Session Libraries for Kecik Framework

README 文档

README

Is libraries were created specifically for the Kecik Framework, this library This library is made to facilitate the use of cookies on the project we build. This library also supports data encryption so that we secure the cookie data.

Installation

Add the following line to the file composer.json located on the project we want to build.

{
    "require": {
        "kecik/kecik": "1.0.*@dev",
        "kecik/cookie": "1.0.*@dev"
    }
}

Next, run the command

composer update

And wait until the update process is completed without error.

Note: This library requires Kecik Framework, so we need to install Kecik Framework first, and then we can install this library.

How to use Cookie Library

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$cookie = new Kecik\Cookie($app);

Whereas if you want a cookie in an encrypted then we simply add the config encryption

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();

//Config for encrypt cookie
$app->config->set('cookie.encrypt', TRUE);
$cookie = new Kecik\Cookie($app);

set()

This Function/Method use for create/update a cookie.

set(string $name, mixed $value)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$cookie = new Kecik\Cookie($app);
$cookie->set('integer', 123);
$cookie->set('string', 'satu dua tiga');
$cookie->set('array', array('satu', 'dua', 'tiga'));

get()

This Function/Method use for get a value from a cookie.

get(string $name)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$cookie = new Kecik\Cookie($app);
$cookie->set('integer', 123);
$cookie->set('string', 'satu dua tiga');
$cookie->set('array', array('satu', 'dua', 'tiga'));

echo 'cookie Integer: '.$cookie->get('integer').'<br />';
echo 'cookie String: '.$cookie->get('string').'<br />';
echo 'cookie Array: ';
print_r($cookie->get('array'));

delete()

This Function/Method use for delete a cookie.

delete(string $name)

Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$cookie = new Kecik\Cookie($app);
$cookie->set('kecik_cookie', 'ini nilai cookie nya');

echo 'kecik_cookie: '.$cookie->get('kecik_cookie').'<br />';

$cookie->delete('kecik_cookie');
echo 'kecik_cookie: '.$cookie->get('kecik_cookie').'<br />';

clear()

This Function/Method use for delete all cookie are exist. Example:

<?php
require "vendor/autoload.php";

$app = new Kecik\Kecik();
$cookie = new Kecik\Cookie($app);

$cookie->clear();

统计信息

  • 总下载量: 163
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-24