public function write($key, $value = null, array $options = []) {
		$expire = (!isset($options['expire']) && empty($this->_config['expire']));
		$cookieClass = __CLASS__;

		if ($expire && $key !== $this->_config['name']) {
			return null;
		}
		$expires = (isset($options['expire'])) ? $options['expire'] : $this->_config['expire'];

		return function($params) use (&$expires, $cookieClass) {
			$key = $params['key'];
			$value = $params['value'];
			$key = [$key => $value];
			if (is_array($value)) {
				$key = Set::flatten($key);
			}

			foreach ($key as $name => $val) {
				$result = setcookie(
					$cookieClass::keyFormat($name, $this->_config),
					$val,
					strtotime($expires),
					$this->_config['path'],
					$this->_config['domain'],
					$this->_config['secure'],
					$this->_config['httponly']
				);
				if (!$result) {
					throw new RuntimeException("There was an error setting {$name} cookie.");
				}
			}
			return true;
		};
	}