1

I need to send a simple cookie using RCurl. The cookie is "AcceptDisclaimer=yes" I tried doing this:

curl <- getCurlHandle()
curlSetOpt(cookiejar='cookies.txt', curl=curl)
resultingWebPage <- postForm(website, x = result,  curl = curl)

cookies.txt contains AcceptDisclaimer=yes

However, RCurl doesn't seem to send the cookie !

Regards !

MadSeb
  • 7,958
  • 21
  • 80
  • 121

2 Answers2

3
cookie = 'cookiefile.txt'   
curl  =  getCurlHandle ( cookiefile = cookie,
                         cookiejar = cookie,
                         useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en - US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"
)

# code to do something with web page

rm(curl)
gc()

Use of cookiefile will load the cookie stored in the file. Use of cookiejar will use a temporary cookie

calling rm(curl) and gc() will remove the curl session and cause the cookie file to be written to disk.

Thomas
  • 43,637
  • 12
  • 109
  • 140
Mischa Vreeburg
  • 1,576
  • 1
  • 13
  • 18
1

See How do I use cookies with RCurl? which points to http://www.omegahat.org/RCurl/RCurlJSS.pdf. Section 4.4 of that document details how cookies can be loaded. It uses the cookiefile, not cookiejar, option and the format of the file is more complicated than what you have.

Community
  • 1
  • 1
Brian Diggs
  • 57,757
  • 13
  • 166
  • 188