Zebra_cURL::cookies PHP Method

cookies() public method

This method will automatically set the CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE options.
public cookies ( string $path ) : void
$path string The path to a file to save to / retrieve cookies from. If file does not exist the library will attempt to create it, and if it is unable to create it will trigger an error. @return void
return void
    public function cookies($path)
    {
        // file does not exist
        if (!is_file($path)) {
            // attempt to create it
            if (!($handle = fopen($path, 'a'))) {
                // if file could not be created, trigger an error
                trigger_error('File "' . $path . '" for storing cookies could not be found nor could it automatically be created! Make sure either that the path to the file points to a writable directory, or create the file yourself and make it writable', E_USER_ERROR);
            }
            // if file could be create, release handle
            fclose($handle);
        }
        // set these options
        $this->option(array(CURLOPT_COOKIEJAR => $path, CURLOPT_COOKIEFILE => $path));
    }