Welcome Guest, Not a member yet? Register   Sign In
Session Help
#1

[eluser]ShawnMA[/eluser]
I realize this is a belabored topic, but being new to CI, I've read thru most of the docs, but I must be overlooking something when it comes to correctly setting/getting sessions.

I've followed the configurations found in this post and can confirm that FF is storing a cookie: http://ellislab.com/forums/viewthread/178904/

The way my app is set up, users select values from 2 dropdowns, those values are then put into session variables and a new view is called. From within the new view I need to be able to access the session variables and pass them along to query my db. As it currently stands, when I view the query, no session values are being sent to it.

All assistance is greatly appreciated! Thanks!

**EDITED: My session variables are not being set when I call, $this->session->set_userdata($searchData); - Any thoughts? ***

Here's my code for setting:

Code:
public function goSearch(){
            if( !empty( $_POST ) ) {
                $this->load->library('session');                
                $searchData = array(
                   'eventtypeID'  => serialize($this->input->post('pEventType')),
                   'venuecityID'  => serialize($this->input->post('pVenueCity'))                  
               );
              $this->session->set_userdata($searchData);              
              $this->_displayPublicPage('search', NULL); /*this simply loads some values and redirects to a new view */
                      
           }
        }


Here's my function for getting to pass to the query:

Quote:public function readEvents(){
$eventTypeID = $this->session->userdata('eventtypeID');
$venueCityID = $this->session->userdata('venuecityID');
echo json_encode($this->event_model->getSearchEvents($eventTypeID, $venueCityID));
}
Here's my query in my model:

Code:
public function getSearchEvents($eventTypeID, $venueCityID){          
        $eventTypeID = intval($eventTypeID);
        $venueCityID = intval($venueCityID);
    
        $this->db->select('*');        
        $this->db->where('event_status =', 'A');
        $this->db->where('eventtype.eventtype_id =', $eventTypeID);
        $this->db->where('city.city_id =', $venueCityID);
        $this->db->join('eventtype', 'event.fk_eventtype_id = eventtype.eventtype_id');
        $this->db->join('venue', 'event.fk_venue_id = venue.venue_id');
        $this->db->join('city', 'venue.fk_city_id = city.city_id');
        $this->db->join('tickets', 'event.event_id = tickets.fk_event_id');
        $this->db->from('event');
      
       $this->db->_compile_select();    
        $q = $this->db->get();
       echo $this->db->last_query();                
        if( $q->num_rows() > 0 ) {
            return $q->result();
        } else {
            return array();
        }
        
   }




Theme © iAndrew 2016 - Forum software by © MyBB