PHP code example of ongr / cookies-bundle
1. Go to this page and download the library: Download ongr/cookies-bundle 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/ */
ongr / cookies-bundle example snippets
class AppKernel extends Kernel
{
public function registerBundles()
{
return [
// ...
new ONGR\CookiesBundle\ONGRCookiesBundle(),
];
}
// ...
}
class CookieController
{
use ContainerAwareTrait;
public function updateAction()
{
/** @var JsonCookie $cookie */
$cookie = $this->container->get('project.cookie.foo');
$cookie->setValue(['bar']);
// Cookie has been marked as dirty and will be updated in the response.
$cookie->setExpiresTime(2000000000);
return new JsonResponse();
}
}