Ready to get started?Download WordPress


Setting cookies in wp_remote_post (1 post)

  1. Elio Rivero
    Posted 2 years ago #

    I'm using wp_remote_post and download_url to fetch a zip file from a site using aMember to manage users and access to files. The download_url function works perfectly if the file is not restricted (some files are marked as free and do not require login).

    $response = wp_remote_post( 'http://visit.me/member/login.php', array(
        'headers' => array(),
        'body' => array(
            'amember_login' => $_POST['username'],
            'amember_pass' => $_POST['password']
        'cookies' => array()
    //response check goes here
    $temp_file = download_url( 'http://visit.me/member/downloads/file.zip' );

    However, I need to set a cookie for the login and set it properly. In the code above, I've tried

    'cookies' => array('cookie' => 'cookiejar.txt')

    'cookies' => array('cookiejar.txt')
    and variations adding a full path but keep getting

    Call to a member function getHeaderValue() on a non-object in

    What's the correct way of writing this parameter? I haven't found a single example of its usage, either in the Codex or any wp-related blog.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.