constanze-standard/cookies
Composer 安装命令:
composer require constanze-standard/cookies
包简介
Cookie support for PSR-7 response.
README 文档
README
Cookie support for PSR-7 response.
Installation
composer require constanze-standard/cookies
Usage
Add a Cookie to collection with addCookie.
use ConstanzeStandard\Cookies\Cookie; use ConstanzeStandard\Cookies\CookieCollection; $cookie = new Cookie('name', 'value', 60); $cookieCollection = new CookieCollection(); $cookieCollection->addCookie($cookie);
Or you can add cookie with method add, it will return the new created Cookie instance:
use ConstanzeStandard\Cookies\CookieCollection; $cookieCollection = new CookieCollection(); /** @var \ConstanzeStandard\Cookies\Cookie $cookie */ $cookie = $cookieCollection->add('name', 'value', 60);
The cookie's arguments:
string $nameThe name of the cookie.string $valueThe value of the cookie.int $expireTimeThe time of cookie expires relatively to current timestamp.string $pathThe path on the server in which the cookie will be available on.string $domainThe (sub)domain that the cookie is available to.bool $secureIndicates that the cookie should only be transmitted over a secure HTTPS connection from the client.bool $httponlyWhen TRUE the cookie will be made accessible only through the HTTP protocol.
You can set default value for domain and secure with construct of CookieCollection.
$cookieCollection = new CookieCollection('localhost', true);
If you add a cookie with empty domain or secure, the collection will use the default value.
Set cookies for PSR-7 response:
/** * @var \Psr\Http\Message\ResponseInterface $response * @var \Psr\Http\Message\ResponseInterface $newResponse */ $newResponse = $cookieCollection->makeResponse($response);
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-09-27