1. Go to this page and download the library: Download phpcraftdream/figcookies library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpcraftdream / figcookies example snippets
use PHPCraftdream\FigCookies\Cookies;
// Get cookies from request
$cookies = (new Cookies)->fromRequest($request);
// Get cookies from response
$cookies = (new Cookies)->fromResponse($response);
// Render the Cookie headers and add them to the headers of a
// PSR-7 Request.
$request = $cookies->toRequest($request);
// Render the Set-Cookie headers and add them to the headers of a
// PSR-7 Response.
$response = $cookies->toResponse($response);
use PHPCraftdream\FigCookies\Cookies;
$cookie = (new Cookies)->fromRequest($request)->get('theme');
$cookie->isNew(); //true if no cookie by the specified name exists
//...
$cookie->getValue();
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromRequest($request);
$cookies->get('theme')->setValue('acme');
$request = $cookies->toRequest($request);
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromRequest($request);
$cookies->delete('theme');
$request = $cookies->toRequest($request);
use PHPCraftdream\FigCookies\Cookie;
$cookie = (new Cookie('lu'))
->setValue('Rg3vHJZnehYLjVg7qi3bZjzg')
->setExpires('Tue, 15-Jan-2013 21:47:38 GMT')
->setMaxAge(500)
->rememberForever()
->setPath('/')
->setDomain('.example.com')
->setSecure(true)
->setHttpOnly(true)
;
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromResponse($response);
$cookie = $cookies->get('theme');
use PHPCraftdream\FigCookies\Cookie;
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromResponse($response);
$response = $cookies
->add(
(new Cookie('token'))
->setValue('a9s87dfz978a9')
->setDomain('example.com')
->setPath('/firewall')
)
->toResponse($response);
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromResponse($response);
$cookie = $cookies->get('visitCount');
$cookie->setValue($cookie->getValue() + 1);
$response = $cookies->toResponse($response);
use PHPCraftdream\FigCookies\Cookies;
$response = (new Cookies)
->fromResponse($response)
->delete('theme')
->toResponse($response);
use PHPCraftdream\FigCookies\Cookies;
$cookies = (new Cookies)->fromResponse($response);
$cookies->get('session_cookie')->expire();
$response = $cookies->toResponse($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.