in reply to Re: WWW::Mechanize::Firefox save_url doesn't send cookies
in thread WWW::Mechanize::Firefox save_url doesn't send cookies

I played around some more. My last report was erroneous, adding nsIWBP.PERSIST_FLAGS_FORCE_ALLOW_COOKIES does fix the problem! I had thought it didn't as I was updating the old .pm file not the new version, so my changes weren't even executing (doh!).

So the following lines in save_url fixes it and now it works great!!!! Thanks for the great perl module, opens up a whole new world of mech'ing.

obj_Persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_FROM_CACHE;
obj_Persist.persistFlags = obj_Persist.persistFlags | nsIWBP.PERSIST_FLAGS_FORCE_ALLOW_COOKIES;

  • Comment on Re^2: WWW::Mechanize::Firefox save_url doesn't send cookies

Replies are listed 'Best First'.
Re^3: WWW::Mechanize::Firefox save_url doesn't send cookies
by Corion (Patriarch) on Mar 08, 2011 at 22:58 UTC

    Great! Thanks for testing again and confirming that this works. I'll release a new version with the bugfix (and a privacy warning) some time in the next few days. The code will be changed to the following, to support earlier versions of Firefox 3 that don't have the flag yet:

    obj_Persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_FROM_CACHE | nsIWBP["PERSIST_FLAGS_FORCE_ALL +OW_COOKIES"] ;

    I just want to also ship a local test server to actually confirm locally that the appropriate cookies are sent.

      I double-checked the wireshark captures after the bugfix and it is sending (just) the proper cookies, and not any out-of-domain ones. So it seems to be working as you'd expect.

      PS: There's one other place in your .pm (save_content) where perhaps this PERSIST_FLAGS_FORCE_ALLOW_COOKIES should be added as well. Just search on the other instance of PERSIST_FLAGS_FROM_CACHE. I don't use that other function, so I haven't tested it.