ytake / hack-cookie
HHVM and Hack Cookies for facebook/hack-http-request-response-interfaces.
Fund package maintenance!
ytake
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 3
Open Issues: 0
Language:Hack
Requires
- hhvm: ^4.44
- facebook/hack-http-request-response-interfaces: ^0.3
- hhvm/hhvm-autoload: ^3.0
- hhvm/hsl: ^4.0
Requires (Dev)
- facebook/fbexpect: ^2.7
- hhvm/hacktest: ^2.0
- hhvm/hhast: ^4.0
- hhvm/hsl-experimental: ^4.50
- ytake/hungrr: ^0.13.2
This package is auto-updated.
Last update: 2024-12-14 14:19:35 UTC
README
Managing Cookies for facebook/hack-http-request-response-interfaces.
Supported Only Hack library. Required HHVM >= 4.41.0
Installation
$> composer require ytake/hack-cookie
Basic Usage
Request Cookies
use type Ytake\HackCookie\Cookie; $cookie = Cookie::create('theme', 'blue');
Get a Request Cookie
use type Ytake\HackCookie\RequestCookies; use type Ytake\Hungrr\{Request, Uri}; use namespace HH\Lib\IO; $request = new Request(Message\HTTPMethod::GET, new Uri('/'), IO\request_input); $cookie = RequestCookies::get($request, 'theme'); $cookie = RequestCookies::get($request, 'theme', 'default-theme');
Set a Request Cookie
use type Ytake\HackCookie\RequestCookies; use type Ytake\Hungrr\{Request, Uri}; use namespace HH\Lib\IO; $request = new Request(Message\HTTPMethod::GET, new Uri('/'), IO\request_input); $request = RequestCookies::set($request, Cookie::create('theme', 'blue'));
Modify a Request Cookie
use type Ytake\HackCookie\{Cookie, Cookies, RequestCookies}; use type Ytake\Hungrr\{Request, Uri}; use namespace HH\Lib\IO; $modify = (Cookie $cookie) ==> { return $cookie->getValue() |> $cookie->withValue($$); } $request = new Request(Message\HTTPMethod::GET, new Uri('/'), IO\request_input); $request = RequestCookies::modify($request, 'theme', $modify);
Response Cookies
use type Ytake\HackCookie\{SameSite, SetCookie}; SetCookie::create('lu') ->withValue('Rg3vHJZnehYLjVg7qi3bZjzg') ->withExpires(new \DateTime('Tue, 15-Jan-2020 21:47:38 GMT')) ->withMaxAge(500) ->withPath('/') ->withDomain('.example.com') ->withSecure(true) ->withHttpOnly(true) ->withSameSite(SameSite::LAX);
and more.