Peel the onions and slice them thinly, then cover with balsamic vinegar, cognac and half of the sugar, and let them macerate for at least 2 hours. Put the onions into a saucepan and let them stew on low heat.
After sweating the onions, add the remaining sugar and bring to the boil. Stir continuously and cook until the compote is homogeneous and smooth.
You can check for the setting point of your jam using the "saucer test": when the mixture has thickened, put some compote on a saucer and tilt it. If it does not flow away easily, the compote is ready!