rafaeldms/cookie
Composer 安装命令:
composer require rafaeldms/cookie
包简介
A simple component way to work with Cookies
README 文档
README
The Cookie is a component for creating Cookies in the browser with the possibility to create, read, edit and remove cookies.
O Cookie é um componente para criação de Cookies nos navegadores tendo a possibilidade de criar, ler, editar e remover cookies.
Highlights
- Simple Installation (Instalação simples)
- Easy get instance (Fácil de instanciar)
- Total controle of the cookies (Controle total dos cookies)
- Create cookies with base_64 encryption (Crie cookies com criptografia base_64)
- Composer ready and PSR-2 compliant (Pronto para o composer e Compatível com PSR-2)
Installation
Cookie is available via Composer:
"rafaeldms/cookie": "^1.*"
or run
composer require rafaeldms/cookie
Documentation
For details on how to use the Cookie, see the sample folder with details in the component directory
Para mais detalhes sobre como usar o Cookie, veja a pasta de exemplo com detalhes no diretório do componente
To start using the Cookie you can Instantiate a new Class or use it in an abstract way
Para começar a usar o Cookie pode Instanciar uma nova Classe ou utilizando métodos estáticos
Create Cookie using static methods (Criando cookies usando o método estático)
use RafaelDms\Cookie\StaticCookie; /** * Create a new cookie using the static method */ StaticCookie::setCookie::set("test", "new_test", 10);
Get Cookie using static methods (Obter Cookie usando métodos estáticos)
/** * get value the static method */ echo StaticCookie::get("test"); echo "<br><br>";
Create values as array (Criando valores em array)
/** * Create value as array */ StaticCookie::set('user', ['name' => 'Rafael', 'role' => "Developer"], 10);
Get Cookie using static methods (Obter Cookie usando métodos estáticos)
/** * get value as array the static method */ echo StaticCookie::get('user')['role']; echo "<br><br>";
Delete cookie using static method (Deletar cookie usando método estático)
/** * remove the static class */ StaticCookie::destroy('test');
Create if it doens't exist using method static (Criando um cookie se não existir usando método estático)
/** * create if it doesn't exist the static method */ StaticCookie::setDoesntHave('testIfDoesntHave', true, 10000);
Create and delete if it exists the static method (Criando e deletando um cookie se existir usando método estático)
/** * create if it doesn't exist the static method */ StaticCookie::setDoesntHave('testIfDoesntHave', 'ok', 12500, "/admin", true);
Check if exists using a static method (Verificando se um cookie existe usando método estático)
/** * check if exists cookie the static class */ if (StaticCookie::has('testIfDoesntHave')) { echo "Cookie testIfDoesntHave exist"; } else { echo "Cookie testIfDoesntHave not exist"; } echo "<br><br>";
Check if exists by value using a static method (Verificando se um cookie existe um valor usando método estático)
/** * check if exists by value */ if (StaticCookie::has("testIfDoesntHave", 1)) { echo "the value is equal to ok"; } else { echo "the vlaue is no equal to ok"; } echo "<br><br>";
Instance a new cookie object (Instanciando um novo objeto cookie)
use RafaelDms\Cookie\Cookie; /** * Create a new cookie using construct method */ $cookie = new Cookie("testCookie");
Set methods
Set value
/** * set value a cookie using methot set */ $cookie->setValue("123456");
Set expiryTime
/** * set expiryTime */ $cookie->setExpiryTime(24 * 60 * 60);
Set path
/** * set path */ $cookie->setPath("/admin");
Set domain
/** * set domain */ $cookie->setDomain("https://www.cagep.com.br");
Set http only
/** * set httpOnly to false */ $cookie->setHttpOnly(false);
Set secure only
/** * set secure only to true */ $cookie->setSecureOnly(true);
Save and set
/** * save a cookies */ $cookie->saveAndSet(); var_dump($cookie);
Get methods
Get value
/** * get value */ echo "Value: " . $cookie->getValue(); echo "<br><br>";
Get expire time
/** * get expire time */ echo "Expire Time: " . $cookie->getExpiryTime(); echo "<br><br>";
Get path
/** * get path */ echo "Path: " . $cookie->getPath(); echo "<br><br>";
Get domain
/** * get domain */ echo "Domain: " . $cookie->getDomain(); echo "<br><br>";
Is http only
/** * is http only */ echo "Http only: " . ($cookie->isHttpOnly() ? 'true' : 'false'); echo "<br><br>";
Is secure only
/** * is secure only */ echo "Secure only: " . ($cookie->isSecureOnly() ? 'true' : "false"); echo "<br><br>";
Update value (set new value)
/** * update value */ $cookie->setValue("910111213"); var_dump($cookie);
Check if exists cookie and delete cookie
/* * check if exists cookie and delete cookie */ if($cookie->hasCookie()){ var_dump($cookie); }
Delete and unset cookie
/** * delele cookie and unset */ $cookie->deleteAndUnset(); var_dump($cookie);
Contributing
Please see CONTRIBUTING for details.
Support
Security: If you discover any security related issues, please email rafael@cagep.com.br instead of using the issue tracker.
Se você descobrir algum problema relacionado à segurança, envie um e-mail para rafael@cagep.com.br em vez de usar o rastreador de problemas.
Thank you
Credits
- Rafael Damasceno Ferreira (Developer)
- Cagep Consultoria (Team)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
rafaeldms/cookie 适用场景与选型建议
rafaeldms/cookie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 136 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「https」 「component」 「cookie」 「csrf」 「xss」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rafaeldms/cookie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rafaeldms/cookie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rafaeldms/cookie 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
FSi DataSource Component
A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.
URL routing framework and requests/responses handler for PHP
Library implement an Online Certificate Status Protocol (OCSP) responder
Priveate for SkeekS CMS
统计信息
- 总下载量: 136
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-07