I have an issue which to me does not make any logical sense. I don't know if it is a bug or something I am completely missing. I have a ControllerBase file which sets a few session variables depending on the url. For instance if it is /fr it will save "fr" to the session. I then have another controller that builds the html href lang tags to display in the layout. Each different language option is saved in the database. This function simply loops through the different options and creates the suitable tag. This function has absolutely no interaction with the user session. I can execute the database query with no issue, but as soon as it starts looping it writes over the previously saved session variable.
Controller Base
<?php
$language_get = Languages::findFirst(array(
"region_code=:region_code: AND language_code=:language_code:",
"bind" => array(
"region_code" => $region_code,
"language_code" => $language_code
)
));
$this->session->language = $language_get;
Page Controller
<?php
$href_langs = $this->utils->href_langs();
Utils
<?php
public function href_langs()
{
// Session variable still contains initial valid value here.
$href_languages = Languages::find(array(
"region_code <> 'gb'",
"order" => "language_name ASC"
));
// Session variable still contains initial valid value here.
foreach($href_languages as $href){}
// Session variable value has changed by here.
}
I am completely stumped, if anyone can advise or assist, I would be very grateful.