HTTP Location Redirect Information with PHP’s Curl Extension for development

If you have to deal with HTTP Location headers or HTTP Cookies then being able to see full header output is important.

Seeing every single redirect is very simple using Curl.  Being able to see each cookie header can also be important.  For example, what if your code is deleting and then setting a cookie several times just prior to sending the headers?  Reviewing the HTTP headers can assist you in improving your code and minimizing HTTP redirects.  Using curl can also provide you with redirect time and other useful page information by using the curl_getinfo function.

An example PHP script that can print out useful information about the HTTP header Location and HTTP cookies can be found here.

Example output is below (May be outdated, check the GIT Readme):

(Please see http_headers.txt output for a full list of headers from all requests during redirection.)

Initial URL:
Effective URL:
Redirect Count: 2
Redirect Time: 0.193121
HTTP Cookie Data:
# Netscape HTTP Cookie File
# This file was generated by libcurl! Edit at your own risk. FALSE / TRUE 1478826642 GAPS 1:agP-Dwh5TjL_-TCR_TyE1V8tmTlyyA:_AKh5RagJyJV-Rrj FALSE / TRUE 0 GALX H6aIpryb0s8