Welcome Guest, Not a member yet? Register   Sign In
problem regarding session problem . i can`t store session value passing through jquery ajax.
#1

[eluser]Anchal Gupta[/eluser]
Hi everyone,
i have the problem regarding storing session value
i am not able to increment session count variable
which call through the jqery ajax with some value passing
to function and also
my previous set array which i store in session is change with the
the new one
what is my problem i point out step wise
1>when i use one controller function
startOnlineTest($testid=0)
i set session countnew as 0
Code:
$this->session->set_userdata('countnew',0);
and in view i use jquery to pass data to other function of same controller
Code:
public function ResponseOnline($qid,$response)
using change effect of jquery
Code:
echo "[removed]$(document).ready(function(){";
         foreach($question['childQuestion'] as $q=>$aq){  //
echo "\$(\"input:radio[name=qid-$q]\").live('change',function(){
var sr=\$(\"input:radio[name=qid-$q]:checked\").map(function() {
          return $(this).val();
          }).get().join();
       var qid = \$(\"input:radio[name=qid-$q]\").attr(\"qaid\");
       "; echo "\$.get('"; echo base_url();echo "testpapers/ResponseOnline/'+qid+'/'+sr,{},function(data)
{\$('#res').html(data)});
});";}
echo"});[removed]" ;
this is script is working fine

now the problem is this i get the session value overwrite by the current one although i
use array my code for ResponseOnline
is


Code:
public function ResponseOnline($qid,$response)
  {
  echo "this" .$this->session->userdata('countnew'); // this is not echo as set above by function  startOnlineTest($testid=0)[/color]
     i set session countnew as
     $this->session->set_userdata('countnew',0)
  
echo $d=$qid; // i know its no use but to save time as tested on $d

$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 is incrementes session value";    
echo $this->session->userdata('countnew');
$r2[$d]=$s;                               // store array value $r2 with key $d and value $s
$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
  

}


i get the result for say for first call is fine but for second call my value is overwrite session show Array([32323]=>23)) if i pass function (32323,23) if i pass (33,42)
i get Array([33]=>42) my old value is destroyed

[Please Help Me]


Messages In This Thread
problem regarding session problem . i can`t store session value passing through jquery ajax. - by El Forum - 07-06-2012, 10:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB