I finally managed to make it recursive - so now i have a drop-in SESSIONS monitor that i am very pleased with and would like to share with you
Put the main function call in your header include so it will appear in all pages - you'll see a grey rectangle containing the phrase "see the sessions" - when you click on it the sessions div will become visible - if you click on the sessions div it will disappear
the functions are here :
function addSpaces($level){
$spaces = "";
for($i=1;$i<=($level*3);$i++){
$spaces .= " ";
}
return $spaces;
}
function echoSessionsInner($arry,$level){
$level += 1;
foreach ($arry as $key => $value) {
if(is_array($value)){
$html .= addSpaces($level)."<strong>".$key."</strong><br />\n";
$html .= echoSessionsInner($value,$level);
$html .= "<br />\n";
}else{
$html .= addSpaces($level).$key." = ".$value."<br />\n";
}
}
return $html;
}
function echoSessions(){
$html = "";
$html .= "<div id=\"sessionsLink\" onclick=\"toggleTarget('sessions','block');\" style=\"padding:1px;border:#999999 1px solid; background-color:#EBEBEB;width:100px;\">See the sessions</div>
<div id=\"sessions\" onclick=\"toggleTarget('sessions','none');\" style=\"display:none;\">";
$html .= echoSessionsInner($_SESSION,0);
$html .= "</div>";
return $html;
}
you put this in your header include (you can comment it out to stop it showing)
<?php echo echoSessions(); ?>
and here's the javascript for toggling the div display :
// onclick="toggleTarget('div_id','block_or_none')"
function toggleTarget(what,how){
if(document.getElementById){
document.getElementById(what).style.display=how;
}
}
hope this is of some use to someone - i haven't tested it anywhere apart from in FF2 on WinXP but it should work in most situations