Using a loop, foreachyou can get the names of both keys and the corresponding values using this syntax:
foreach ($your_array as $key => $value) {
// Use $key for the name, and $value for the value
}
So in your case:
foreach($_SESSION as $name => $value) {
echo 'Current session variable is: ' . $value . ' ; the name is ' . $name . '<br />';
}
source
share