void oidc_util_set_chunked_cookie(request_rec *r, const char *cookieName,
		const char *cookieValue, apr_time_t expires, int chunkSize,
		const char *ext) {
	int i = 0;
	int cookieLength = strlen(cookieValue);
	char *chunkValue = NULL;

	/* see if we need to chunk at all */
	if ((chunkSize == 0)
			|| ((cookieLength > 0) && (cookieLength < chunkSize))) {
		oidc_util_set_cookie(r, cookieName, cookieValue, expires, ext);
		oidc_util_clear_chunked_cookie(r, cookieName, expires, ext);
		return;
	}

	/* see if we need to clear a possibly chunked cookie */
	if (cookieLength == 0) {
		oidc_util_set_cookie(r, cookieName, "", expires, ext);
		oidc_util_clear_chunked_cookie(r, cookieName, expires, ext);
		return;
	}

	/* set a chunked cookie */
	int chunkCountValue = cookieLength / chunkSize + 1;
	const char *ptr = cookieValue;
	for (i = 0; i < chunkCountValue; i++) {
		chunkValue = apr_pstrndup(r->pool, ptr, chunkSize);
		ptr += chunkSize;
		oidc_util_set_cookie(r,
				oidc_util_get_chunk_cookie_name(r, cookieName, i), chunkValue,
				expires, ext);
	};
	oidc_util_set_cookie(r, oidc_util_get_chunk_count_name(r, cookieName),
			apr_psprintf(r->pool, "%d", chunkCountValue), expires, ext);
	oidc_util_set_cookie(r, cookieName, "", expires, ext);
}
void oidc_util_set_chunked_cookie(request_rec *r, const char *cookieName,
		const char *cookieValue, apr_time_t expires, int chunkSize,
		const char *ext) {
	int i = 0;
	int cookieLength = strlen(cookieValue);
	char *chunkValue = NULL;

	 
	if ((chunkSize == 0)
			|| ((cookieLength > 0) && (cookieLength < chunkSize))) {
		oidc_util_set_cookie(r, cookieName, cookieValue, expires, ext);
		oidc_util_clear_chunked_cookie(r, cookieName, expires, ext);
		return;
	}

	 
	if (cookieLength == 0) {
		oidc_util_set_cookie(r, cookieName, "", expires, ext);
		oidc_util_clear_chunked_cookie(r, cookieName, expires, ext);
		return;
	}

	 
	int chunkCountValue = cookieLength / chunkSize + 1;
	const char *ptr = cookieValue;
	for (i = 0; i < chunkCountValue; i++) {
		chunkValue = apr_pstrndup(r->pool, ptr, chunkSize);
		ptr += chunkSize;
		oidc_util_set_cookie(r,
				oidc_util_get_chunk_cookie_name(r, cookieName, i), chunkValue,
				expires, ext);
	};
	oidc_util_set_cookie(r, oidc_util_get_chunk_count_name(r, cookieName),
			apr_psprintf(r->pool, "%d", chunkCountValue), expires, ext);
	oidc_util_set_cookie(r, cookieName, "", expires, ext);
}