• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
session problem in pagination

#1
[eluser]rajyakshmik[/eluser]
When i m cliking pagination i m losing session value,How to rectify this prob..

#2
[eluser]Thorpe Obazee[/eluser]
You're probably doing something wrong....

Show your code and someone is bound to answer.

#3
[eluser]rajyakshmik[/eluser]
//view code
function dealsearch()
{

if(document.form1.zip.value=='' && document.form1.keywords.value=='')
{
document.form1.zip.value=0;
document.form1.keywords.value=0;
document.form1.action="main/search/N";
}
if(document.form1.zip.value!='' && document.form1.keywords.value=='')
{
document.form1.keywords.value=0;
document.form1.action="main/search/S1";
}
if(document.form1.zip.value=='' && document.form1.keywords.value!='')
{
document.form1.zip.value=0;
document.form1.action="main/search/S2";
}
else
{
document.forms[0].action="main/search/S";
}
//document.form1.action="main/search/S";
}

<form method="post" name="form1">
<div id="Layer4">

</div>
<div id="Layer5">
<div id="Layer6">
<table width="98%" height="69" border="0" align="center" cellspacing="0">
<tr>
<td colspan="7">&nbsp;<img src="images/searchdeal.jpg" /></td>
</tr>
<tr>

<td width="12%" align="right" class="dealsearch" >ZipCode</td>
<td width="14%">
&lt;input type="text" name="zip" width="20" tabindex="7" size="5" maxlength="5" value="&lt;?php if($_SESSION['zip']!='') echo $_SESSION['zip'];?&gt;"/&gt; </td>
&lt;!--<<td width="12%" align="right" class="dealsearch">Business Type </td>
<td width="22%">select name="businesstype" tabindex="8"><option value="0">--Select Business Type--</option>

&lt;?php

//foreach ($query2->result() as $row)
// {


?&gt;
<option value='&lt;?php //echo $row->MerchantType;?&gt;' &lt;?php //if($_SESSION['businesstype']!='') { if($row->MerchantType == $_SESSION['businesstype']) //echo "selected"; }?&gt; >&lt;?php //echo $row->MerchantType;?&gt;</option>";

&lt;?php // }
?&gt;
</select></td>--&gt;
<td width="9%" align="right" class="dealsearch">Keywords</td>
<td width="26%">
&lt;input type="text" name="keywords" width="20" size="30" tabindex="9" value="&lt;?php if($_SESSION['keywords']!='') echo $_SESSION['keywords'];?&gt;"/&gt;&lt;/td>
<td width="12%">&lt;input type="image" src="images/searchbtn.jpg" border="0" tabindex="10" &gt;&nbsp;&nbsp;</td>
</tr>
</table>
</div>
</div>
&lt;/form&gt;
//Controller code
function search($key)
{
$condi ='';
$codetype='';
$data['msg'] ='';
if($key == 'S')
{
if($_POST['zip']!='0')
$_SESSION['zip'] = $_POST['zip'];

if($_POST['keywords']!='0')
$_SESSION['keywords'] = $_POST['keywords'];

}
else if($key == 'S1')
{
if($_POST['zip']!='0')
$_SESSION['zip'] = $_POST['zip'];

}
else if($key == 'S2')
{
// echo '===>'.$_POST['keywords'];
if($_POST['keywords']!='0')
$_SESSION['keywords'] = $_POST['keywords'];

}
else if($key == 'N')
{

$_POST['zip']='';
//$_POST['businesstype']='';
$_POST['keywords']='';
$_SESSION['keywords']='';
//$_SESSION['businesstype']='';
$_SESSION['zip']='';
}
else
{
//echo 'sfsdf';
$_POST['zip']='';
//$_POST['businesstype']='';
$_POST['keywords']='';
$_SESSION['keywords']='';
//$_SESSION['businesstype']='';
$_SESSION['zip']='';
}
//echo '===>'.$_SESSION['keywords'];
if($_SESSION['zip']!='')
{
$condi.= " and merchants.zip ='$_SESSION[zip]'";
}
/* if($_SESSION['businesstype']!=0)
{
$condi.= " and merchants.MerchantType ='$_SESSION[businesstype]'";
}*/

#4
[eluser]TheFuzzy0ne[/eluser]
Please wrap your code in [code] [/code] tags.

#5
[eluser]rajyakshmik[/eluser]
//view code
Code:
function dealsearch()
{

  if(document.form1.zip.value==’’ && document.form1.keywords.value==’‘)
  {
      document.form1.zip.value=0;
      document.form1.keywords.value=0;
      document.form1.action=“main/search/N”;
  }
  if(document.form1.zip.value!=’’ && document.form1.keywords.value==’‘)
  {
      document.form1.keywords.value=0;
      document.form1.action=“main/search/S1”;
  }
  if(document.form1.zip.value==’’ && document.form1.keywords.value!=’‘)
  {
      document.form1.zip.value=0;
      document.form1.action=“main/search/S2”;
  }
  else
  {
      document.forms[0].action=“main/search/S”;
  }
  //document.form1.action=“main/search/S”;
}

&lt;form method=“post” name=“form1”&gt;
  <div id=“Layer4”>

  </div>
  <div id=“Layer5”>
  <div id=“Layer6”>
    <table width=“98%” height=“69” border=“0” align=“center” cellspacing=“0”>
      <tr>
      <td colspan=“7”> images/searchdeal.jpg</td>
      </tr>
      <tr>
            
      <td width=“12%”  align=“right” class=“dealsearch” >ZipCode</td>
      <td width=“14%”>
      &lt;input type=“text” name=“zip” width=“20” tabindex=“7” size=“5” maxlength=“5” value=”&lt;?php if($_SESSION[‘zip’]!=’‘) echo $_SESSION[‘zip’];?&gt;”/&gt;    </td>
      <!—<<td width=“12%” align=“right” class=“dealsearch”>Business Type </td>
      <td width=“22%”>select name=“businesstype” tabindex=“8”><option value=“0”>—Select Business Type—</option>
    
        &lt;?php
      
        //foreach ($query2->result() as $row)
        // {
        
          
            ?&gt;
              <option value=’&lt;?php //echo $row->MerchantType;?&gt;’  &lt;?php //if($_SESSION[‘businesstype’]!=’‘) { if($row->MerchantType == $_SESSION[‘businesstype’])    //echo “selected”; }?&gt; >&lt;?php //echo $row->MerchantType;?&gt;</option>”;
        
        &lt;?php // }
          ?&gt;
      </select></td>—>
      <td width=“9%” align=“right” class=“dealsearch”>Keywords</td>
      <td width=“26%”>
      &lt;input type=“text” name=“keywords” width=“20” size=“30” tabindex=“9” value=”&lt;?php if($_SESSION[‘keywords’]!=’‘) echo $_SESSION[‘keywords’];?&gt;”/&gt;&lt;/td>
      <td width=“12%”>&lt;input type=“image” src=“images/searchbtn.jpg” border=“0” tabindex=“10” &gt;  </td>
      </tr>
    </table>
  </div>
  </div>
  &lt;/form&gt;
//Controller code
function search($key)
  {
      $condi =’‘;
      $codetype=’‘;
      $data[‘msg’] =’‘;
      if($key == ‘S’)
      {
        if($_POST[‘zip’]!=‘0’)
        $_SESSION[‘zip’] = $_POST[‘zip’];
      
        if($_POST[‘keywords’]!=‘0’)
        $_SESSION[‘keywords’] = $_POST[‘keywords’];
    
      }
    else if($key == ‘S1’)
      {
        if($_POST[‘zip’]!=‘0’)
        $_SESSION[‘zip’] = $_POST[‘zip’];
    
      }
      else if($key == ‘S2’)
      {
        // echo ‘===>’.$_POST[‘keywords’];
        if($_POST[‘keywords’]!=‘0’)
        $_SESSION[‘keywords’] = $_POST[‘keywords’];
    
      }
      else if($key == ‘N’)
      {
    
        $_POST[‘zip’]=’‘;
        //$_POST[‘businesstype’]=’‘;
        $_POST[‘keywords’]=’‘;
        $_SESSION[‘keywords’]=’‘;
        //$_SESSION[‘businesstype’]=’‘;
        $_SESSION[‘zip’]=’‘;
      }
      else
      {
        //echo ‘sfsdf’;
        $_POST[‘zip’]=’‘;
        //$_POST[‘businesstype’]=’‘;
        $_POST[‘keywords’]=’‘;
        $_SESSION[‘keywords’]=’‘;
        //$_SESSION[‘businesstype’]=’‘;
        $_SESSION[‘zip’]=’‘;
      }
      //echo ‘===>’.$_SESSION[‘keywords’];
      if($_SESSION[‘zip’]!=’‘)
      {
        $condi.= ” and merchants.zip =’$_SESSION[zip]’”;
      }
    /* if($_SESSION[‘businesstype’]!=0)
      {
        $condi.= ” and merchants.MerchantType =’$_SESSION[businesstype]’”;
      }*/

#6
[eluser]narkaT[/eluser]
does your app use cookies to store the session id?

#7
[eluser]rajyakshmik[/eluser]
Yes .I m using
Code:
$config['sess_cookie_name']        = 'ci_session';

#8
[eluser]TheFuzzy0ne[/eluser]
You should be using $this->input->post() to access the post array, and $this->session->set_userdata() for setting session data.

#9
[eluser]rajyakshmik[/eluser]
same problem.I m using like this

Code:
else if($key == 'S1')
        {
            $session = array(
                           'zip' => $this->input->post('zip')                
                           );
             $this->session->set_userdata($session);
        }

Code:
if($this->session->userdata('zip')!='')
        {
            $szip = $this->session->userdata('zip');
            $condi.= " and merchants.zip ='$szip'";
        }

#10
[eluser]TheFuzzy0ne[/eluser]
Please attach the file containing all of your controller code.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.