0
我此行我的兩個功能:爲什麼會話在這一行中自動殺死/破壞?
function buildmenu($iduser){
$ghead = $this->mnu->get_head()->result();
$i = rand(0,100);
$menu = "";
foreach ($ghead as $h){
$i++;
$access = $this->mnu->get_access($h->IDMenu,$iduser)->row()->Access;
if ($access != "0"){
$menu .= "<li class='hasSubmenu glyphicons $h->MenuIcon'>";
$menu .= "<a data-toggle='collapse' href='#mnu_systemtea$i'><i></i><span> $h->MenuDesc </span></a>";
$menu .= $this->buildchild($i,$h->IDMenu,$iduser);
$jmlchild= $this->mnu->get_jml_child($h->IDMenu);
$menu .= "<span class='count'>$jmlchild</span>";
$menu .= "</li>";
}
}
return $menu;
}
function buildchild($i=NULL,$idparent,$iduser){
$tchild = $this->mnu->get_child($idparent)->result();
$int = rand(5000,6000);
if ($tchild != NULL){
$child = "<ul class='collapse' id='mnu_systemtea$i' >";
foreach ($tchild as $c){
$access = $this->mnu->get_access($c->IDMenu,$iduser)->row()->Access;
$int++;
if ($access != '0'){
if ($c->HasSubMenu == 1){
$child .= "<li class='hasSubmenu'>";
$child .= "<a data-toggle='collapse' href='#mnu_systemtea$int'><span>$c->MenuDesc </span></a>";
$child .= $this->buildchild($int,$c->IDMenu,$iduser);
$jmlchild = $this->mnu->get_jml_child($c->IDMenu);
$child .= "<span class='count'>$jmlchild</span>";
$child .= "</li>";
}
if ($c->HasSubMenu == 0){
$cek_this_parent = $this->mnu->get_menu($idparent)->row()->IDParent;
if ($cek_this_parent == 0){
$child .= "<li>";
$child .= "<ul>";
$child .= "<li>";
$child .= "<a url-mod='$c->URLMod' url-det='$c->URLDet' ><span> $c->MenuDesc </span></a>";
$child .= "</li>";
$child .= "</ul>";
$child .= "</li>";
}
else{
$child .= "<li>";
$child .= "<a url-mod='$c->URLMod' url-det='$c->URLDet' ><span> $c->MenuDesc </span></a>";
$child .= "</li>";
}
}
}
}
$child .= "</ul>";
return $child;
}
}
我打電話功能buildmenu()
,並將其插入到一個會話變量:
function sess_menu(){
$menu = $this->buildmenu("0579120613");
$this->session->set_userdata('sess_menu',$menu);
}
function index(){
echo $this->session->userdata('sess_menu'); // i echo menu here
}
通過buildmenu()
功能內置的菜單顯示,第一次我調用index()
函數,但是第二次,依此類推,sess_menu
會話爲空。就像它被摧毀了一樣。會議有沒有問題?是控制器和模型之間的連接可以使任何會話被破壞?