Apify Discord Mirror

Updated 5 months ago

Cookies are not saving to KeyValue pairs

At a glance

The community member is trying to test out sessionPool and set default cookies for each session. They create a sessionPool with specific options, then try to set cookies for a session and check if they are properly set. However, the session1.getCookies() always returns an empty array. The community member is asking for a solution and suggestions on how to debug this issue further.

The comments from other community members do not provide any explicit answers, but one member congratulates the original poster on advancing to level 7.

Useful resources
Dear all I am trying to test out sessionPool and preparing each session with some default cookies. I create a sessionPool like this

const sessionPool_de = await SessionPool.open({ maxPoolSize: 25, sessionOptions:{ maxAgeSecs: 10, maxUsageCount: 150, // for example when you know that the site blocks after 150 requests. }, persistStateKeyValueStoreId: 'main_session', persistStateKey: 'location-specific-session-pool', });

This is how I set cookies and then try to see if the cookies are properly set for this session. But its always empty and I dont see any cookies in keyvalue pairs as well.

var session1 = await sessionPool_de.getSession(); var proxyurl = await proxyConfigurationEU.newUrl(session1.id); console.log(proxyurl); var cookies_g =[ { name: 'cookie1', value: 'my-cookie' }, { name: 'cookie2', value: 'your-cookie' } ] console.log("orignal cookies ",cookies_g, "Session_main", session1.id); session1.setCookies( cookies_g, 'https://www.example.com' ); console.log("getting cookies", session1.getCookies("www.example.com"));

My session1.getCookies always returns empty. Any solution for it ? how can I debug it further ?
A
c
2 comments
just advanced to level 7! Thanks for your contributions! πŸŽ‰
do you have some suggestions ?
Add a reply
Sign up and join the conversation on Discord