Session variables, How can i get all the defined keys?
Moderator: General Moderators
Session variables, How can i get all the defined keys?
I'm wanting to put a session object though a "for each loop". all i really want is the name and value of all the keys in a session. Can any body help me.
Have you tried:
This worked for me, let me know if it does for you?
Code: Select all
<?php
session_start();
$_SESSION['user'] = "nigma";
$_SESSION['blah'] = "blah";
foreach ($_SESSION as $sessValue)
{
print $sessValue;
}
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
To expand on nigma's answer:
Mac
Code: Select all
foreach ($_SESSION as $key => $value) {
echo 'key = '.$key.' and value = '.$value.'<br />';
}array_keys and array_values should be of interest as well.