定制 miladrahimi/phpcookie 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

miladrahimi/phpcookie

最新稳定版本:1.5

Composer 安装命令:

composer require miladrahimi/phpcookie

包简介

Free PHP cookie tools for neat and powerful projects!

README 文档

README

Free PHP cookie tools for neat and powerful projects!

Documentation

PHPCookie is a tiny package for working with cookies and encrypting them. It implemented the easy way to access and manipulating cookies with assuming security issues. This package uses PHPCrypt package for encryption.

Installation

Using Composer

It's strongly recommended to use Composer. If you are not familiar with Composer, The article How to use composer in php projects can be useful. After installing Composer, go to your project root directory and run following command there:

composer require miladrahimi/phpcookie

Or if you have composer.json file already in your application, you may add this package to your application requirements and update your dependencies:

"require": {
    "miladrahimi/phpcookie": "~1.5"
}
composer update

Manually

You can use your own autoloader as long as it follows PSR-0 or PSR-4 standards. In this case you can put src directory content in your vendor directory.

Getting Started

It's so easy to use! It uses PHPCrypt package to encrypt and decrypt data. So if you use Composer everything will be ok otherwise you must download this package too. After installation of this package you must inject it to Cookie class. See the example to grasp all what you need to know:

use MiladRahimi\PHPCookie\Cookie;
use MiladRahimi\PHPCrypt\Crypt;

$project_key = "3303a3f4640d601566c02cb8fe16d96e";

$crypt = new Crypt();
$crypt->setKey($project_key);

$cookie = new Cookie();
$cookie->setCrypt($crypt);

$cookie->set("Singer", "Pink Floyd");
  • First of all, you must set your project key to the instance of Crypt class.
  • Second of all, you must inject Crypt object to Cookie class via Cookie::setCrypt() method.
  • You can use Cookie::set() and Cookie::get() to set and get data in cookies.
  • The Cookie::set() parameters matches with native PHP setCookie function.

Getting data from cookies

There is get() method in Cookie class which you can use to get data from cookie.

echo $cookie->get("Singer");

Encryption

All cookies will be encrypted. If you set cookie via this package, you have to use this package to get it too.

PHPCookieException

There are some situation which PHPCookieException will be thrown. Here are methods and messages:

  • Crypt object is not set in Cookie::set() when you use this method before injecting Crypt instance to the class.
  • Crypt object is not set in Cookie::get() when you use this method before injecting Crypt instance to the class.
  • The cookie value not exists in Cookie::get() when you trying to get some cookie value which not exists.

Contributors

Homepage

License

PHPCookie is released under the MIT License.

miladrahimi/phpcookie 适用场景与选型建议

miladrahimi/phpcookie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 70 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「security」 「cookies」 「cookie」 「Cookie Security」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 miladrahimi/phpcookie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 miladrahimi/phpcookie 我们能提供哪些服务?
定制开发 / 二次开发

基于 miladrahimi/phpcookie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 70
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-10