Get website cookie after login

My friends, sorry to bother you.

I’m starting now on n8n and I need a little help.

I have some sites, and I need to extract the cookie from them and forward to an external location.

However, when he inhales, I need to generate a new cookie.

Any solution for this?

Anyone with an idea, thanks.

I tried that, but still, I can’t get just the cookie.

I’ll keep trying, if anyone can help, I appreciate it.

Thanks!

Hi @denverfix, looks like you’ve found the relevant header :slight_smile:

So what’s left here is finding the right cookie seeing your page is sending multiple cookies in the set-cookie header and then extracting its value. You could for example use JMESPath for the job.

Assuming you want to fetch the localization cookie from https://merch.n8n.io/, a possible workflow could look like so:

In addition to JMESPath, I am also using .split() to split up the header value into the relevant parts.

The result would be the actual cookie value. Hope this helps!

Hello @MutedJam ,

Thanks for trying to help me!

I want to generate the cookie when I login to the site.

Does the event generate the cookie all the time?

Thanks !

I want to generate the cookie when I login to the site.

Hi @denverfix, in that case you’d need to adjust the example so it reflects the requests sent when signing in through your browser.

Does the event generate the cookie all the time?

This depends on the page you are logging into. Assuming there’s no documentation you might need to simply try it out. In most cases the cookie will be good for multiple requests, but depending on the exact page you are using it might require a fresh cookie for every single request.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.