SMF Using Cookies to show debugger

There is a way to use cookies to show the debugger in SMF. This does require modifications of your code and generally is being used for positioning in customized site setups

First off, you will need to place some code on your site. You can use $context[‘user’][‘is_admin’] to hide and show it. You will need to use CSS to build some sort of button/clicker identifier. I won’t go over that here as I assume your already customizing your SMF install.

		echo '
	<a id="smf_admin_clicker"></a>
	<script type="text/javascript">
		$("#smf_admin_clicker").click(function() {
			var oCookie = new smc_Cookie({});
			var cookieValue = oCookie.set("smf_debugger", ', !empty($_COOKIE['smf_debugger']) ? 0 : 1, ');
			location.reload();
		});
	</script>';

Now with this installed, you can do something like this in your Settings.php

$db_show_debug = !empty($_COOKIE['smf_debugger']) ? true : false;

This has no security as all it will take is somebody to guess your cookie name to enable debugging. You should ensure the cookie name is unlikely to be guessed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.