public function get_secure_url_token($generate = false)
    {
        if ($len = $this->config->get('use_secure_urls')) {
            if (empty($_SESSION['secure_token']) && $generate) {
                // generate x characters long token
                $length = $len > 1 ? $len : 16;
                $token  = rcube_utils::random_bytes($length);

                $plugin = $this->plugins->exec_hook('secure_token',
                    array('value' => $token, 'length' => $length));

                $_SESSION['secure_token'] = $plugin['value'];
            }

            return $_SESSION['secure_token'];
        }

        return false;
    }