Get Cookie After Login

Hello,

I would like to get a cookie after logging into an app where I don’t have an api, just a login form.

Using Postman or Insomnia I can login and get the cookie successfully, I really tried it in every way, of course I’m using node Http Requests, read in other questions that say to enable the Full Response option to true, but not yet I can choose the cookie in the headers.

My goal is to use the cookie to perform an update on the next node.

See my response headers after submit

Welcome to the community @Edson_Rodrigues

Can you try without the redirect?

Hi Ricardo,

N8n is very nice, congratulation the community. I am appreciation.

When I set the redirect false I can get the cookie but as it gives the error “object moved” due to the app redirecting to the dashboard after login I can’t run the workflow.

See,

Hey @Edson_Rodrigues!

Welcome to the community :sparkling_heart:

Apart from the cookie, do you need anything else in the next nodes of your workflow? Since this HTTP Request node is not giving an error, it is simply returning the body of the webpage, the next node in your workflow should get executed.

Hi.

Follow all redirects is set to true, my workflow is working, but I can’t get cookie in the next node due to the redirect.

Follow all redirects is set to false, my workflow doesn’t work, but I can see the cookie is in the headers, but I can’t get it next node, because the workflow stops.

Hey @Edson_Rodrigues,

Thank you for sharing the information. With the previous screenshot, I thought you were getting a successful output. I am not sure how this can be handled. Can you share the workflow via DM? It will help me replicate the issue

Hi,

Thank you for your help.
Now I can run my workflow by setting Ignore Response to true.
When I get the object moved error the workflow runs successfully.

Success work.

2 Likes

Thank you for sharing the solution! I am sure this will other members as well :slight_smile:

I have a workflow that has stopped working.

Yesterday, when upgrading to the latest version of n8n, I can no longer access the cookie.

I’m trying to find out what could be wrong.

Does anyone have any ideas.

See my prints…


1 Like

I downgraded to version 0.138.0 and went back to work.

I’m trying to understand what changed in version 0.139.1

1 Like

That must have to do with our switch from the request library to axios as the former got deprecated.

We will check what is going on there exactly and try to release a fix with the next version.

If you want to use 0.139.1 you can temporarily also set the environment variable N8N_USE_DEPRECATED_REQUEST_LIB=true to keep on using the request library also in this new version till it got fixed.

2 Likes

Thanks for the guidance.
I will follow this tip.

Hello @Edson_Rodrigues

I created a pull request that should fix the issue you’re having. You can follow it here: Fix 'ignore response code' flag in http request node by krynble · Pull Request #2284 · n8n-io/n8n · GitHub

Should be merged and released soon.

Very good job @krynble.
Thanks a lot for sharing the solution.

Fix got released with [email protected]

1 Like

Hi,
Are you sure it’s fixed? Because with version 0.144.0 it doesn’t work. We have to use the flag or rollback to make it work.

Thanks.

Thanks for reporting this, @mast_ats. @krynble is the man for this and he’s out until Monday, but he’ll help get to the bottom of this as soon as he can.

I’m on 0.145.0 and had this problem. The request node was just retuning an empty json response, no response headers at all.

I set the N8N_USE_DEPRECATED_REQUEST_LIB=true and it works now.

Unfortunately I can’t provide more details I have none really, but will gladly provide any info necessary to replicate the problem (Just not the entire workflow)

Hi @mast_ats

Can you provide more details? The scenario that I fixed and works fine is:

  • Turn on Full Response on HTTP Request node
  • Turn on Ignore Response on HTTP Request node
  • Disable Follow all redirects on HTTP Request node

I created a mock where a fake endpoint returns a Set-cookie header along with Location header and a status code of 301 or 302. For both situations, this worked fine. The redirect was not made and the http request node returned the headers correctly.

Could you please also check these settings @Couto ?

Thanks!

@krynble The settings you mentioned were my initial settings when the request was failing to return the response body.
However, in my scenario, the server returns a 303 response status.