Page 1 of 1

libcurl and cookies

Posted: Tue Oct 17, 2006 2:05 am
by is_null
This is the cookie.txt generated by libcurl :

Code: Select all

# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.templatehelp.com	FALSE	/	FALSE	0	PHPSESSID	1a347f89f6d5aa534b7c3b9c18384499
secure.template-help.com	FALSE	/aff/	FALSE	1192644656	aff	test
secure.template-help.com	FALSE	/	FALSE	1192644656	aff	test
www.templatehelp.com	FALSE	/	FALSE	1192610687	aff	test
www.templatehelp.com	FALSE	/aff/	FALSE	1192610687	aff	test
Could anybody please tell me the relation between the pair of collumns 1 and 3 (first column is 0) please ?
I don't know wheter the first is stands for secure or httponly

Code: Select all

bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, bool secure [, bool httponly]]]]]] )
Thank you in advance

Posted: Tue Oct 17, 2006 2:39 am
by Weirdan

Posted: Tue Oct 17, 2006 2:47 am
by is_null
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thank you very much. I wonder why i had to download this text as zip file though ...
[quote]Netscape COOKIE.TXT Files
=========================

The layout of Netscape's cookies.txt file is such that each line 
contains
one name-value pair. An example cookies.txt file may have an entry that
looks like this:

 .netscape.com     TRUE   /  FALSE  946684799   NETSCAPE_ID  100103

Each line represents a single piece of stored information. A tab is
inserted between each of the fields.

From left-to-right, here is what each field represents:

* domain - The domain that created AND that can read the variable.

* flag - A TRUE/FALSE value indicating if all machines within a given
domain can access the variable. This value is set automatically by the
browser, depending on the value you set for domain.

* path - The path within the domain that the variable is valid for.

* secure - A TRUE/FALSE value indicating if a secure connection with the
domain is needed to access the variable.

* expiration - The UNIX time that the variable will expire on. UNIX time 
is
defined as the number of seconds since Jan 1, 1970 00:00:00 GMT.

* name - The name of the variable.

* value - The value of the variable.[/quote]

If you want to reproduce curl's client cookie on the visitor, i use :

Code: Select all

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
		curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
                curl_exec($ch);
		//echo file_get_contents("cookie.txt");
		$cookie_array = explode("\n", file_get_contents("cookie.txt"));
		foreach ($cookie_array as $key => $line)
		{		
			$inline_keys = explode("\t", $line);
			setcookie($inline_keys[5], $inline_keys[6], $inline_keys[4], $inline_keys[2], $inline_keys[0], $inline_keys[3], $inline_keys[1]);
		}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]