duandaotuo5542 2012-10-19 13:28
浏览 35

可能的原因Curl php脚本未在预定义文件上获取/保存cookie - 权限和路径导致排除

Ok, I've tried a various scripts that I found and none of them worked. I'm interested why very basic PHP Curl scripts are not working? Is it about XAMPP? Here is, for example, my code

$ckfile = $_SERVER['DOCUMENT_ROOT']  .'/cookies'  . '/cookies.txt';

$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, "http://example.com/"); // of courese, have cookies
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);

curl_exec($ch);


curl_close($ch);   

which should return cookies in my cookies.txt file. Why is this not happening? Notices: Ownership is not problem (I have tried with different) Permissions is not problem (made 777) Checked file_exists($ckfile), file exists.

  • 写回答

1条回答 默认 最新

  • duanlu6114 2012-10-20 11:42
    关注

    I found the reason. No one mentioned that besides ownership, permissions, full path and so, cookie you trying to save to local file must be server side cookie, not the cookies set by javascript.

    Hopes someone will find this helpful.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器