Jump to content

Curl request with cookie


ratcateme

Recommended Posts

maybe this will help:

<?php
$Month = 2592000 + time();
//this adds 30 days to the current time
setcookie(AboutVisit, date("F jS - g:i a"), $Month);
?>

 

I found it here:

http://php.about.com/od/advancedphp/qt/php_cookie.htm

 

You could also take a look at one of these:

http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=how+to+set+a+cookie+in+PHP

<?php
$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL,$url );
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields); 
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12");
	curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_REFERER, $reffer);
$html = curl_exec ($ch);
	curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
    	curl_close ($ch);
?

 

Whats in my cookie.txt:

# Netscape HTTP Cookie File
# http://curlm.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

en.mapleeurope.com	FALSE	/	FALSE	0	ASP.NET_SessionId	ru4s2wzve0uypn453fxdn255
.mapleeurope.com	TRUE	/	FALSE	2147483647	EMSUserAreaInfo	UserCountryCode=NL&UserIPAddress=68.61.224.221
.mapleeurope.com	TRUE	/	FALSE	0	pageLan	1nDyHvJz5W8=

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.