How to set a real session ID through the browser for webhooks

Just as a solution on how to really set a session id, that will automatically be transported. (Webhook will answer like a real website with the session ID, which the browser stores and will automatically send if there is a followup request to the same webhook)

In Reference to the closed thread:

What it does:

  1. checks if the session cookie was available like any website would do
    • params required by the webhook: {model: "models/gemini-2.0-flash", chatInput: "tell me ..."}
  2. create one if missing, or sets the one that was provided
  3. respond with the correct set-cookie header (so the calling website will know if the session (in case of a browser, it will automatically send the session-cookie on next request)

Yes: this is how being logged in works: using session cookies.

The long version: (both yield the same result)