Tip: Debug on a live site only for you (yes even with a shared IP)

There was a bug on one of our live sites which required some level of debugging. Unfortunately with my CakePHP app turning on debugging meant a whole lot of nastiness that would appear for users of the website. I needed to see the debug information on the live site without affecting any other users (including my bosses in the same office, which meant I couldn’t just turn on debugging for our office IP address).

Here’s what I did:

  • Download User Agent Switcher
  • Setup a new User Agent and copy “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 FirePHP/0.3  Debugger” in there. It’s important to keep the firefox related information in there as this allows hacks and stuff to continue knowing that it’s Firefox making the request
  • Setup a condition in your code that checks if “Debugger” is present in the user agent string and turns on debugging if so.

My condition code looks this:

if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Debugger') !== false ) {
	$debug = 2;
}

Enjoy full debug freedom on a production site!

One Comment

  1. Posted March 31, 2010 at 10:03 pm | Permalink

    Nice tip buddy. just wondering where to put the if condition ?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">