I'm trying to make sessions based off sql query data is being returned
this is my code:
$r = self::$db->fetch_row_assoc($sql);
$theme_dir = THEME_PATH . self::get_useragent() . "_UA_" . $flag . "_" . $r['theme_folder_name'];
if (self::$config['set_session'] == 1) {
foreach ($r as $k => $v) {
self::$session->set(self::get_useragent() . "_UA_" . $flag . "_" . $k, $v);
}
self::$session->set(self::get_useragent() . "_UA_" . $flag . "_theme_loaded", 1);
}
when this code is run the makes my sessions but i get something like
$_SESSION['Default_UA_landing_theme_id'] = 1
$_SESSION['Default_UA_landing_0'] = 1
it does this for every session that it creates, it makes 1 session with $k being the field name of the result returned by my query then it makes another with $k being the index of the $r array.
how can I just have it make one session per $k?
this is the method I use to query my datase
public function fetch_row_assoc($statement)
{
self::$PDO->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try{
$stmt = self::$PDO->query($statement);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$result = $stmt->fetch(PDO::FETCH_BOTH); //FETCH_BOTH
return $result;
}catch(PDOException $e){
echo $e->getMessage();
}
return false;
}