79615996

Date: 2025-05-10 22:48:42
Score: 1
Natty:
Report link

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

Reasons:
  • Probably link only (1):
  • Contains signature (1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • High reputation (-1):
Posted by: BananaAcid