I have a login page that collects clients mapped a certain user upon login.
$query_acct = "select client from app_reports.user_map where user_name = '".$username."'";
$acct = $DB_con->prepare($query_acct);
$acct->execute();
$row_acct = $acct->fetchAll(PDO::FETCH_ASSOC);
if (!empty($row_acct['client'])){
foreach($row_acct as $r) {
$client[] = $r['client'];
}
$_SESSION['client'] = $client;
}
As I understood it, $_SESSION['client']
should store the array stored in $client
.
But when I attempted to print it out with:
foreach($_SESSION['client'] as $key=>$value){
// and print out the values
echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />';
}
I'm getting: Notice: Undefined index: client
Warning: Invalid argument supplied for foreach()
I'd like to get some advice on how to store an array in a session properly so I can print them out (will be used as a dropdown, etc.)