public function value($value = null)
    {
        if (is_null($value)) {
            throw new \InvalidCookieException('Cookie value cannot be null.');
        }

        if (is_array($value)) {
            $value = json_encode($this->security->sanitize($value));
        }

        $length = (function_exists('mb_strlen') ? mb_strlen($value) : strlen($value));

        if ($length > 4096) {
            throw new \InvalidCookieException('Cookie maximum size exceeds 4kb');

            return false;
        }

        $this->value = $this->security->sanitize($value);

        return $this;
    }