I am using file_get_contents to get the content of an external website. This however lets me only view the content if I accept cookies. Is there a way that I can accept this cookie?
@stephan_gerlachauthorMar 19.2007 — #This is what I have [code=php] $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.domain.com'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); $data = curl_exec($ch); curl_close($ch); [/code]
not sure what the code really does but it is not working. How can I find out if the cookies the website (i.e. www.domain.com ) is setting or trying to set?
@bokehMar 19.2007 — #This however lets me only view the content if I accept cookies[/QUOTE]This doesn't make any sense. How does the remote site know you are not saving the cookie? Are there multiple requests?
@NightShift58Mar 19.2007 — #not sure what the code really does but it is not working.[/QUOTE]What isn't working?
If the website/page wants you to accept cookies, it's probably because it sets them somewhere else and on this particular page, it's only checking if you've accepted it in the past.
You may have to "backup",by which I mean use cURL to get another page where the cookie is being sent/set, store it and then go to the page where the site is checking for the existence of the cookie (multiple request, as Bokeh alluded).
Is the page you're trying to get "public" - can anyone see it?