I'm building a web bot to login into some of my accounts on websites but one of the url's are sending cookie from javascript and curl is unable to store them. Any suggestion?
You could parse the javascript file using whatever language your using and look for the document.cookie statement. You could then use this data to set the cookie manually in curl. (CURLOPT_COOKIE)
It wouldn't exactly be the best idea if your hoping for this to work with a number of sites, but since you state that you know the site you'll need to load its a possibility as you'll have an idea of how the Javascript will look.
If you have months of free time on your hands, you could compile webkit and its javascript engine and modify the cookie-setting functionality so that it exports the cookies to stdout
(and then grab them with PHP's exec
). Good luckkk with that though. Considering you're asking this question with relation to cURL, I don't think this is quite up your alley...
I'd sort of go with Kewley's answer if you're desperate though. You should be able to reverse-engineer the javascript and see the logic behind how the web application sets its cookies. If it authenticates and returns the login-result with XHR, watch what's sent and received by the browser (with Firebug). Add breakpoints on the document.cookie
lines and observe what cookies are being set (and what they're being set to). Once you know the precise logic behind authentication, you perform the necessary behind-the-scenes requests necessary to snag a session on the site with cURL.