I am using puppeteer to run headless chrome. Once I login I want to keep the session cookies for future use. Is there a way to save and load session cookies in puppeteer?
Looking for something like:
(async () => {
console.log('start -> ', true);
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setUserAgent(agent);
await page.setViewport({width: 1280, height: 699});
await page.goto('https://www.website.com/');
await login(); // custom method for log in
// here --->
const sessionCookies = await page.cookies.toJSON();
// and in another session --->
await page.setCookies(cookiesJson);
})();
You should be able to use
page.cookies()