Page 1 of 1
Session variables, How can i get all the defined keys?
Posted: Tue Oct 07, 2003 7:36 pm
by Roo
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.
Posted: Tue Oct 07, 2003 7:42 pm
by nigma
Have you tried:
Code: Select all
<?php
session_start();
$_SESSION['user'] = "nigma";
$_SESSION['blah'] = "blah";
foreach ($_SESSION as $sessValue)
{
print $sessValue;
}
?>
This worked for me, let me know if it does for you?
Posted: Wed Oct 08, 2003 4:32 am
by twigletmac
To expand on nigma's answer:
Code: Select all
foreach ($_SESSION as $key => $value) {
echo 'key = '.$key.' and value = '.$value.'<br />';
}
Mac
Posted: Wed Oct 08, 2003 8:37 am
by nigma
Oops, sorry, I read to quickly. You probably already knew how to do what I replied with.
Posted: Wed Oct 08, 2003 8:53 am
by patrikG
array_keys and
array_values should be of interest as well.
Posted: Wed Oct 08, 2003 8:01 pm
by Roo
Thanks for all your help guys every thing worked fine.
your all Champs
Gog bless
Roo