0
當我通過ajax jQuery傳遞一些值到function ResponseOnline($qid,$response)
時,我不能同時存儲新的會話值和舊的會話值。在ajax jquery調用codeigniter中的函數後會話值被破壞
這裏是我的問題
。在登錄後的一些價值商店
。然後我傳遞一些值通過ajax jquery來運行,然後將它存儲在數組中然後在會話中。
。當我通過ajax jquery獲得會話值時,我得到正確的東西,
。但是,當我通過第二個值,然後我損失我的會話價值,我 已存儲在前一遍。
這裏是我的函數調用:
public function ResponseOnline($qid,$response)
{
$d=$qid;
$s=$response;
if($this->session->userdata('countnew')==0) // algo for this function i check the
//countnew session varaible if 0 do this
{
$sc=$this->session->userdata('countnew'); // store the countnew variable
echo $sc=$sc+1; // increment the counter variable
$this->session->set_userdata('countnew',$sc); // store it in session
echo $this->session->userdata('countnew');
$r2[$d]=$s; // store array value $r2 with key $d and
$this->session->set_userdata('res',$r2); //set this array value in session
}
else{ // if session countnew!=0 then do this
$r2=$this->session->userdata('res'); // first store $r2 as array return from session
$r2[$d]=$s; //then add value to this array
$this->session->set_userdata('res',$r2); // storing this array to session
}
echo '<pre>';
print_r($r2); // printing the array
}