for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @name OpenImporter
* @copyright OpenImporter contributors
* @license BSD https://opensource.org/licenses/BSD-3-Clause
*
* @version 1.0
*/
namespace OpenImporter;
* We need Cooooookies.
* @class Cookie
class Cookie
{
* Cookie constructor.
public function __construct()
}
* Set a cookie
* @param array $data
* @param string $name
* @return boolean
public function set($data, $name = 'openimporter_cookie')
if (!empty($data))
setcookie($name, serialize($data), time()+ 86400);
$_COOKIE[$name] = serialize($data);
return true;
return false;
* Get our cookie
public function get($name = 'openimporter_cookie')
if (isset($_COOKIE[$name]))
return unserialize($_COOKIE[$name], array('allowed_classes' => false));
* Once we are done, we should destroy our cookie
public function destroy($name = 'openimporter_cookie')
setcookie($name, '');
unset($_COOKIE[$name]);
* Extend the cookie with new information
public function extend($data, $name = 'openimporter_cookie')
$cookie = $this->get($name);
if ($cookie !== false)
$merged = array_merge((array) $cookie, (array) $data);
else
$merged = $data;
return $this->set($merged, $name);