My 50 cents to the topic. A one liner to get a cookie value.
I had to add a session check / creation to a webhook in n8n, so I used:
//get:
let sessionKey = $json.headers.cookie.matchAll(/([^;=\s]*)=([^;]*)/g).toArray().find(c => c[1] == 'SESSID')?.reduce((acc, v, k) => k == 2 ? decodeURIComponent(v) : acc, '') ?? '';
Yes, $json.headers.cookie would be need to be the correct request.headers?.cookie array.
n8n Workflow: https://community.n8n.io/t/how-to-set-a-real-session-id-through-the-browser-for-webhooks/113570/1
gist: https://gist.github.com/BananaAcid/42a5a4bdb95678154202ae391232c224