Click to See Complete Forum and Search --> : Printing the Session Object


Evie
01-10-2007, 02:38 PM
I would like to print out the whole contents of the current session to check variables and such.

How would I do that?

TIA

~ e

NickG21
01-10-2007, 02:42 PM
print_r($_SESSION)

Evie
01-10-2007, 02:48 PM
Thank you!

NightShift58
01-11-2007, 01:45 AM
... and if you need more details than print_r() delivers, try var_dump($_SESSION)
See: http://us2.php.net/manual/en/function.var-dump.php

Evie
01-11-2007, 07:21 AM
Thanks again :)

MrCoder
01-11-2007, 09:02 AM
I like using the following function when developing sites.


<?php
function var_dump_html($mixed, $die=false, $clean=false)
{
if($clean)
while(@ob_end_clean());
echo "<pre>\n";
var_dump($mixed);
echo "</pre>\n\n";

if($die)
die();
}

ob_start();
?>

<p>Some text that never gets displayied</p>

<?php
var_dump_html(array("Data_one" => 1, "Data_two" => 2), false, true);
?>

<p>Some more text that will be shown</p>

<?php
var_dump_html("A string");
?>

<p>Some more text that will be shown</p>

<?php
var_dump_html($_SERVER, true);
?>

<p>This is not shown since the above var_dump_html call forced a die()</p>

Evie
01-11-2007, 09:34 AM
whoo hoo, thanks :)