public function setCookie($name, $value, $expires = 0, $path = null) {
        if (!is_string($name)) throw new IllegalTypeException('Illegal type of parameter $name: '.gettype($name));
        if (!is_int($expires)) throw new IllegalTypeException('Illegal type of parameter $expires: '.gettype($expires));
        if ($expires < 0)      throw new InvalidArgumentException('Invalid argument $expires: '.$expires);

        $value = (string)$value;

        if ($path === null)
            $path = $this->getApplicationBaseUri();

        if (!is_string($path)) throw new IllegalTypeException('Illegal type of parameter $path: '.gettype($path));

        \setcookie($name, $value, $expires, $path);
    }