Welcome Guest, Not a member yet? Register   Sign In
CI Sessions are killing me. What am I doing wrong here?
#1

[eluser]Unknown[/eluser]
As some of you know, I am still feeling my way around with CI. Considering that I can't do what I want with Pagination, I have to put the passing variables in a session. Here is my dilemma:

I need to post $search_method, $search_keywords (this is an array of keywords), $search_type, $search_miles. Because of the results, I need the same variables to give me the correct results from the database so I need to pass the variables to a session. Don't I have to check to see if there is a session variable and if not, set it? But wouldn't the part where I take the variable from the post and put a variable cause an error since if i am on the next page in the pagination and not posting?

Here is the last thing I tried:

Code:
$sess_search_method = $this->input->post('search_method', TRUE);
  
  if($sess_search_method)
  {
  $this->session->set_userdata('search_method', $sess_search_method);
  echo 'Yep';
  
  }
  else
  {
  $search_method = $this->session->userdata('search_method');
  }
  
  
  $sess_search_type = $this->input->post('search_type', TRUE);
  
  if($sess_search_type)
  {
  $this->session->set_userdata('search_type', $sess_search_type);
  
  
  }
  else
  {
  $search_type = $this->session->userdata('search_type');
  }
  
  
  $sess_search_keywords = $this->input->post('search_keywords', TRUE);
  
  if($sess_search_keywords)
  {
  $this->session->set_userdata('search_keywords', $sess_search_keywords);
  
  
  }
  else
  {
  $search_keywords = $this->session->userdata('search_keywords');
  }
  
  
  $sess_search_miles = $this->input->post('search_miles', TRUE);
  
  if($sess_search_miles)
  {
  $this->session->set_userdata('search_miles', $sess_search_miles);

  }
  else
  {
  $search_miles = $this->session->userdata('search_miles');
  }

I know I probably over did it up there, but I have tried just about everything in the last few hours. Wish I could just use regular PHPSessions, but I want to use the new framework as much as possible.


Messages In This Thread
CI Sessions are killing me. What am I doing wrong here? - by El Forum - 10-02-2011, 04:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB