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

Link to comment
Share on other sites

<?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=

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.