Source Code



Get Header Value Using PHP

  • anonymous
  • Jul 18' 14
  • PHP
  • 160
  • 180
  • United States

First browser request to a web page, browser send a http header in background like this :

Host: localhost
Connection: keep-alive
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: UTF-8,*;q=0.5
Cookie: username=admin; password=21232ffc3; PHPSESSID=o5m4e2td1m66c4pkjdag9vs0u2

 

You can print out to screen what the header values using this function:

 

function showHeaders(){
         foreach($_SERVER as $var => $val ){
         if(substr($var,0,5) == "HTTP_"){
            $headers[str_replace(" ","-",ucwords(strlower(str_repalce("_"," ",substr($var,5)))))] = $val;
            }
          }
         return $headers;
      }
}

 

 Use the function

 

foreach (showHeaders() as $name => $value){
        echo "$name : $value 
";
        }

 

  • Tags : php, header, browser, values
comments powered by Disqus

Related Code

Dumping MySQL Database Using Command

Chart Line Using Morris

PHP vulnerability Scan Script

Fixed Header Menu CSS

Edit Value In Same Page

Subnet Calculator

Execute a JavaScript Code on a TWebBrowser Document

Get Meta Tag Information

Vulnerable Scan Web



Category