• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What Happens After a Controller Method is Done?

#1
[eluser]rrasco[/eluser]
I have session data being changed after the end of the method is called and I have called a view(). Something after everything in the controller and view is happening, any ideas what?

*NOTE: The forums were not liking the siteurl() parameters, so I omitted them.

Code:
function enter($id)
{
    if($this->session->userdata('logged') == 'y') {
        $data['login'] = '<img src="http://carpearticulum.com/arrow.gif">&nbsp;Logged in - <a href="'.site_url().'">Log out</a><br />';
    } else {
        $data['login'] = '<img src="http://carpearticulum.com/arrow.gif">&nbsp;<a href="'.site_url().'">Login</a> or <a href="'.site_url().'">Register</a><br />';
    }
    
    if($this->session->userdata('logged') == 'y') {
        $this->session->set_userdata('contest_id', $id);

        echo $this->session->userdata('contest_id'); // this returns the right value
        exit; // if I stop code here, the value is stored correctly, else it stores 'img'
        // Actually, I can exit the code anywhere before the end of the method and it works
        // but it stops the page from displaying, what happens after a view() call?

        $query = $this->db->select('*');
        $query = $this->db->where('id', $id);
        $query = $this->db->get('contests');
        if ($query->num_rows() > 0) {
                $row = $query->row();
                $data['contest_title'] = $row->title;
                $data['description'] = $row->description;
                $data['prize'] = $row->prize;
                $data['category'] = $row->category;
                $data['start'] = $row->start;
                $data['end'] = $row->end;
                $data['entry_fee'] = $row->entry_fee;
                $this->session->set_userdata('entry_fee', $row->entry_fee);    
        }
        $this->load->view('contests/enter_view', $data);

    } else {

        $this->session->set_userdata('contest_id', $id);
        $this->session->unset_userdata('member_page');
        
        $data['msg'] =  "If already registered please <a href='".site_url()."'>login</a> or please <a href='".site_url()."'>Register</a>";
        $this->load->view('home/login_or_register', $data);
    
    }
    exit; // This works here too, but stops code
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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