Apify and Crawlee Official Forum

Updated 3 months ago

Cookies are not saving to KeyValue pairs

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