SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    curl not store cookies

    hi,

    i have function to log in form
    it should store cookies data in cookies.txt to using it in th next page
    but it does not work

    PHP Code:
    $headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
        
    $headers[] = 'Connection: Keep-Alive';
        
    $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
        

        
    $ch curl_init();

        
    curl_setopt($chCURLOPT_URL$link);
        
    curl_setopt($chCURLOPT_HTTPHEADER$headers);
        
    curl_setopt($chCURLOPT_REFERER$referal);
        
    curl_setopt($chCURLOPT_USERAGENT'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
        
    curl_setopt($chCURLOPT_TIMEOUT'10');
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($chCURLOPT_POSTFIELDS,$data);
        
    curl_setopt($chCURLOPT_COOKIEJAR"cookies.txt");
        
    curl_setopt($chCURLOPT_COOKIEFILE"cookies.txt");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
    curl_setopt($chCURLOPT_HEADER0);
        
    $store curl_exec($ch); 
    the log in successful but not store any data in cookies.txt
    so i can't moved to the next page

    i tested to store data using fwrite in cookies.txt and its success

  2. #2
    SitePoint Guru
    Join Date
    Feb 2008
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this will be much help, but if you are running this code on a Windows installation, you need to set the full path for the cookie file.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks
    its work


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •