23
Views
5
Comments
[Puppeteer] Browser Cookies
puppeteer
Service icon
Forge asset by Stuart Harris
Application Type
Service

Hello, 

I was wondering if it is possible to get the browser cookies and save them in a session variable. 

In my case, im trying to use this component to login on a website so that I can use cookies to use an api. 


Thanks,

Ricardo Oliveira

2025-05-02 20-28-47
Drishti Menghani

Hi @Ricardo Oliveira 

Hope you are well.

One can get the browser cookies using the HTTPRequestHandler's action named GetCookie & set using SetCookie. And can be assigned to Session variables as per requirements. 


 

Hope this will help!

UserImage.jpg
Ricardo Oliveira

Hello @Drishti Menghani ,

Thanks for your answer. What im trying to get are the cookies from Puppeteer so that I can use then on an api call. I think your method does only works if I want to get the Cookies or setting the cookies from the current browser. 


Thanks again,

Ricardo Oliveira

2024-11-07 03-28-42
Stuart Harris
Champion

Hi @Ricardo Oliveira, Thank you for posting a question on the support channel!

Currently the available actions don't access the request cookies. So not currently possible.

However, I could update the component to add an additional actions.

I understand you want to use cookies to call an API. Could you clarify exactly how the API is called, and what information would need to be passed to make the component call the API.

Have a look at the "actions" in the documentation. We would need to create one or more new actions:

https://www.outsystems.com/forge/component-documentation/20769/puppeteer-o11/0

Kind regards,

Stuart 

UserImage.jpg
Ricardo Oliveira

Hello @Stuart Harris 

I am using Puppeteer to login on the external site, I am able to do that. All I need now is to get the "Cookies". Then I am consuming a REST API and the endpoint needs that cookie. 

 Maybe the "Puppeteer_LoginAndBrowse" could return the Cookies. I am not sure if that is possible. 


Thanks,

Ricardo Oliveira

2024-11-07 03-28-42
Stuart Harris
Champion

Thanks for a quick response @Ricardo Oliveira.

The Puppeteer library looks like it can retrieve the cookies ok.

I see, you are looking to retrieve data from the web page and use it for something else.

If you need the browser cookies, I assume you must be calling an API the application is using, except calling it directly. If that is correct then it is a security concern to put the functionality in this component for that purpose.

So I am a little reluctant to add this functionality without verifying that this will not comprise the component in any way.

Kind regards,

Stuart

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.