Extract cookie value from a php file without specifying the name

I am Lakshmi.Research scholar.I have a doubt in the usage of cookies in php.Normally in order to extract the cookie value we have to specify the corresponding cookie name.But I need automatic extraction.If i give a php file,all the cookies in that file should be extracted.Is it possible?

Simple answer, [B]NO!

Because cookies in PHP are just an array of indexes and values, without a given index the cookie can not be found within that array. If you only have one cookie set for an entire domain which sometimes does happen then you can but apart from that no you cant.

Thanks for the reply.Cookies in php have an attribute called domain which contains the domain name.I need to extract this domain value from all the cookies in a page.for each and every cookie i cant get the value by giving the name.Automatically i have to find number of cookies in a page and get the value of domain attribute of all the cookies.Do you think is it possible.

How to automatically extract the cookies in a page?The input should be the php file name,the output should be the number and names of the cookies.Is it possible?

<threads merged>

You can use curl to visit a remote page and collect the cookies the server tries to create, but right now, I’m unsure of what you’re trying to achieve.

I’ll give you a hint. Browsers do not send cookies to any domain but the one they originated from. Nor do they send any information about the cookie other then its name and value. So any cookies you recevice you can assume they are from or for “$_SERVER['HTTP_HOST']”. Example Request and response headers below.

Request from Client (Browser):

GET http://www.sitepoint.com/... HTTP/1.1
Host: www.sitepoint.com
Connection: keep-alive
Cookie: bblastvisit=sssssssss; bblastactivity=0; bbuserid=ssssssssssssss; bbsessionhash=ssssssssssssssssssss;

Response from Server:

HTTP/1.1 200 OK
Set-Cookie: bbrecentviewed=sssssssssssssss; expires=Sun, 05-Jun-2011 07:05:45 GMT; path=/; domain=.sitepoint.com
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive