Web Design
Web Design Surrey Web Design Services in Surrey

Tutorial Categories

Links & Services

Mailing List

For special offers and annoucements, please enter your email address below.

Output All PHP Session Variables

A big problem when using session variables is not knowing if the have been set correctly. This function outputs all the current session variables - allowing you to troubleshoot your app more effectively. You should get output similar to this:

Key font has the value of: 1
Key menuFont has the value of: 12
Key width has the value of: 142
Key lineHeight has the value of: 1.3
Key ih has the value of: 20
Key iw has the value of: 20

How to do it:

Simply add this code where you want to check your variables.

<?php 
if (!isset($_SESSION)) {
session_start(); 
}
while ($var = each($_SESSION)) {  
printf ("Key <b>%s</b> has the value of: <b>%s</b><br>", $var['key'], $var['value']);  
}  
?>

Tip:

If, at any time, you need to remove a session variable completely, you can use unset as follows:

<?php 
unset($_SESSION['Variable_Key']);       
?>


More PHP Tutorials

Recursively Remove Files in Linux

View More...

Output a list of images using PHP

View More...

PHP Dynamically Generated Year Dropdown

View More...

Dynamically Generated PHP Bar Graphs

View More...