Find out what cookies are stored upon login, posting them

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maxedison
Forum Newbie
Posts: 5
Joined: Sun Jul 06, 2008 1:19 pm

Find out what cookies are stored upon login, posting them

Post by maxedison »

I'm trying to write a php script that will automatically log into my Amazon.com Seller Central account and store the source code of a certain page (which can only be accessed after logging in) in a variable. I understand that this is essentially a two step process:

1) Figure out what cookies Amazon creates upon login
2) Sending those cookies through a POST method in the script.

I don't know how to do either, so lets just start with #1. Is there a program that I can download which will monitor this? Or will a certain browser provide me with this information after logging in?

Thanks!

Max
Last edited by maxedison on Tue May 25, 2010 12:41 pm, edited 1 time in total.
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: ind out what cookies are stored upon login, posting them

Post by timWebUK »

Use a packet sniffer such as Wireshark or a web browser plugin so you can see which HTTP headers are sent, then send those yourself using sockets in PHP.

I believe that should work.
maxedison
Forum Newbie
Posts: 5
Joined: Sun Jul 06, 2008 1:19 pm

Re: ind out what cookies are stored upon login, posting them

Post by maxedison »

Tim,

Thanks. I've installed the Firefox addon "Live HTTP Headers" and created a throw-away Amazon account. Upon logging in to that account, I get the following information in the Live HTTP Headers window. Can you tell me if this is the kind of info I need? Please feel free to go into as much detail about the following info as you'd like. I really know nothing about this sort of thing at this point.
https://www.amazon.com/gp/flex/sign-in/select.html

POST /gp/flex/sign-in/select.html HTTP/1.1
Host: http://www.amazon.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: https://www.amazon.com/gp/flex/sign-in/select.html
Cookie: apn-user-id=4104030f-e611-4697-bb5a-0cfa4f807d0b; __utma=194891197.1304726052.1238616173.1263413290.1268864861.4; __utmz=194891197.1268864861.4.3.utmccn=(referral)|utmcsr=developer.amazonwebservices.com|utmcct=/connect/entry.jspa|utmcmd=referral; session-id-time=1282546800l; session-id=182-0521596-6461259; ubid-main=187-5658263-7314765; session-token=WoPbu8Mlf//Wtn9aHmPyvidNpZCqXLw5ZY2LixNFivHihjHcU+nqwK7dPoPxJe94sXHaUwlBQMO6lh1hQHiY4YXD2Gz5D2IZJPRis1XIOT7Y0HCXDlvvi/2S0VZOG0tW5f/g2WhVvJ7NAp9euQgZFMe4FI53R3H3l4uppkJOvZj9quBZsU37K87i/YvSurlhRzU4iBmbq4s=
Content-Type: application/x-www-form-urlencoded
Content-Length: 851
path=%2Fgp%2Fyourstore&useRedirectOnSuccess=1&query=signIn%3D1%26action%3Dsign-out%26useRedirectOnSuccess%3D1%26path%3D%2Fgp%2Fyourstore%26ref_%3Dpd_irl_gw_r&mode=&redirectProtocol=&pageAction=%2Fgp%2Fyourstore&disableCorpSignUp=&protocol=https&sessionId=182-0521596-6461259&referer=flex&accountStatusPolicy=&email=alison.salder%40gmail.com&action=sign-in&password=peach9000&x=0&y=0&metadata1=Firefox+3.6.3+Mac&metadataf1=192-2064364-1802262%3A1253112713&metadata2=Java+Embedding+Plugin+0.9.7.2+Default+Plugin+MoveNetworks+Quantum+Media+Player+071303000006WebEx+General+Plugin+Container+166Facebook+Plug-In+iPhotoPhotocast+6Google+Talk+Browser+Plugin+Microsoft+Office+Live+Plug-in+10Silverlight+Plug-In+40504010Shockwave+Flash+10045Google+Earth+Plug-in+3QuickTime+Plug-in+7.6.6+%7C%7C1920-1200-1174-24-*-*-*&metadata3=timezone%3A+5+execution+time%3A+2
HTTP/1.1 301 MovedPermanently
Date: Tue, 25 May 2010 17:46:39 GMT
Server: Server
x-amz-id-1: 1H2966JYVQCTGNWZK349
p3p: policyref="http://www.amazon.com/w3c/p3p.xml",CP="AMZN "
x-amz-id-2: rXRyPIbvlra8CJ7eur3FDiYBDmtOPQmt
Location: https://www.amazon.com/gp/yourstore?ie= ... n=sign-out
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: x-main=izTRC16fYVlDNoNSglQl6gNa4mhs?CEI; path=/; domain=.amazon.com; expires=Tue Jan 01 08:00:01 2036 GMT
Set-Cookie: at-main=3|dp0Y+FPiIJPkxBpAgCra4NwtDS6f/gCmRnmPin3MyfYMa2IVY/UJtiDD59Rh74CbU9SjAgEunJrbfbgyjLfY/WPjC+QOXXgMvhqXppMBdXWWTIuiJuc5IaPumFBzY5fnBvo/uDdO9iot6+OV5B0QQzS3FJesXNpKZ20dY7hR6HNUr5xEZ26sqwRbY1D0GsIkYW9O3rcdFEE=; path=/; domain=.amazon.com; expires=Tue Jan 01 08:00:01 2036 GMT; secure
Set-Cookie: ubid-main=187-5658263-7314765; path=/; domain=.amazon.com; expires=Tue Jan 01 08:00:01 2036 GMT
Set-Cookie: session-token=9QLv5nSZVMY5Kb082llGRCvzTAvSHfbaMa4Id8IthGao2z2acMkFmC27z3/sAHVtVpnQkcjbHY/t3zlRpoJ1c0mvCgfhOnYoXpJF0qvKhhR0LQ6gBukIaZBqXr9wmdeQ0vytLEYHXBe6HHF7R5bwTKTA/mlRLyCz0X+mcpPs/hEstn/4Pfooor5+jmyjcvXjvG8m+gdYI2FFwZRIhwEkYvd4F0PoC3Otm4me+px5+41n/SjK2Ds/VAibNFHK/+xI; path=/; domain=.amazon.com; expires=Tue May 25 17:56:39 2010 GMT
Cneonction: close
Transfer-Encoding: chunked

----------------------------------------------------------
https://www.amazon.com/gp/yourstore?ie= ... n=sign-out

GET /gp/yourstore?ie=UTF8&path=%2Fgp%2Fyourstore&ref_=pd_irl_gw_r&signIn=1&useRedirectOnSuccess=1&action=sign-out HTTP/1.1
Host: http://www.amazon.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: https://www.amazon.com/gp/flex/sign-in/select.html
Cookie: apn-user-id=4104030f-e611-4697-bb5a-0cfa4f807d0b; __utma=194891197.1304726052.1238616173.1263413290.1268864861.4; __utmz=194891197.1268864861.4.3.utmccn=(referral)|utmcsr=developer.amazonwebservices.com|utmcct=/connect/entry.jspa|utmcmd=referral; session-id-time=1282546800l; session-id=182-0521596-6461259; ubid-main=187-5658263-7314765; session-token=9QLv5nSZVMY5Kb082llGRCvzTAvSHfbaMa4Id8IthGao2z2acMkFmC27z3/sAHVtVpnQkcjbHY/t3zlRpoJ1c0mvCgfhOnYoXpJF0qvKhhR0LQ6gBukIaZBqXr9wmdeQ0vytLEYHXBe6HHF7R5bwTKTA/mlRLyCz0X+mcpPs/hEstn/4Pfooor5+jmyjcvXjvG8m+gdYI2FFwZRIhwEkYvd4F0PoC3Otm4me+px5+41n/SjK2Ds/VAibNFHK/+xI; x-main=izTRC16fYVlDNoNSglQl6gNa4mhs?CEI; at-main=3|dp0Y+FPiIJPkxBpAgCra4NwtDS6f/gCmRnmPin3MyfYMa2IVY/UJtiDD59Rh74CbU9SjAgEunJrbfbgyjLfY/WPjC+QOXXgMvhqXppMBdXWWTIuiJuc5IaPumFBzY5fnBvo/uDdO9iot6+OV5B0QQzS3FJesXNpKZ20dY7hR6HNUr5xEZ26sqwRbY1D0GsIkYW9O3rcdFEE=

HTTP/1.1 200 OK
Date: Tue, 25 May 2010 17:46:39 GMT
Server: Server
x-amz-id-1: 01QNC1SQ3DW5M0EF8KZT
p3p: policyref="http://www.amazon.com/w3c/p3p.xml",CP="AMZN "
x-amz-id-2: bKLPcEucKYSWTFy1AKuqUjORvwi8Vr4o
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: ubid-main=187-5658263-7314765; path=/; domain=.amazon.com; expires=Tue Jan 01 08:00:01 2036 GMT
Cneonction: close
Transfer-Encoding: chunked

----------------------------------------------------------
https://www.amazon.com/gp/history/exter ... ndler.html

POST /gp/history/external/full-rhf-rec-handler.html HTTP/1.1
Host: http://www.amazon.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: https://www.amazon.com/gp/yourstore?ie= ... n=sign-out
Content-Length: 148
Cookie: apn-user-id=4104030f-e611-4697-bb5a-0cfa4f807d0b; __utma=194891197.1304726052.1238616173.1263413290.1268864861.4; __utmz=194891197.1268864861.4.3.utmccn=(referral)|utmcsr=developer.amazonwebservices.com|utmcct=/connect/entry.jspa|utmcmd=referral; session-id-time=1282546800l; session-id=182-0521596-6461259; ubid-main=187-5658263-7314765; session-token=9QLv5nSZVMY5Kb082llGRCvzTAvSHfbaMa4Id8IthGao2z2acMkFmC27z3/sAHVtVpnQkcjbHY/t3zlRpoJ1c0mvCgfhOnYoXpJF0qvKhhR0LQ6gBukIaZBqXr9wmdeQ0vytLEYHXBe6HHF7R5bwTKTA/mlRLyCz0X+mcpPs/hEstn/4Pfooor5+jmyjcvXjvG8m+gdYI2FFwZRIhwEkYvd4F0PoC3Otm4me+px5+41n/SjK2Ds/VAibNFHK/+xI; x-main=izTRC16fYVlDNoNSglQl6gNa4mhs?CEI; at-main=3|dp0Y+FPiIJPkxBpAgCra4NwtDS6f/gCmRnmPin3MyfYMa2IVY/UJtiDD59Rh74CbU9SjAgEunJrbfbgyjLfY/WPjC+QOXXgMvhqXppMBdXWWTIuiJuc5IaPumFBzY5fnBvo/uDdO9iot6+OV5B0QQzS3FJesXNpKZ20dY7hR6HNUr5xEZ26sqwRbY1D0GsIkYW9O3rcdFEE=
Pragma: no-cache
Cache-Control: no-cache
shovelerName=rhf&key=rhf&numToPreload=5&isGateway=0&refTag=pd_rhf_shvl&parentSession=182-0521596-6461259&excludeASIN=&renderPopover=0&forceSprites=0
HTTP/1.1 200 OK
Date: Tue, 25 May 2010 17:46:40 GMT
Server: Server
x-amz-id-1: 1G3E7QC780WP1T57RZQD
p3p: policyref="http://www.amazon.com/w3c/p3p.xml",CP="AMZN "
x-amz-id-2: 6RWuZm8mJrc2NbAMui8ozYKPbv7VXs8R
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: ubid-main=187-5658263-7314765; path=/; domain=.amazon.com; expires=Tue Jan 01 08:00:01 2036 GMT
Cneonction: close
Transfer-Encoding: chunked
----------------------------------------------------------
Max
Post Reply