Welcome Guest, Not a member yet? Register   Sign In
php native session with codeigniter version 1.7.2
#1

[eluser]ranjitbd[/eluser]
Code:
// earlier i was using codeigniter_rapyd_0.9.7 version. where php native session was working
// but now i am using codeigniter 1.7.2 where in the controller native session working but
// not working in the view page
// the controller and the view page is showing below

//controller holiday.php
<?php
class Holiday extends Controller {

    function Holiday()
    {
        parent::Controller();
        $this->load->model($this->config->item('holiday_model'), 'holiday', TRUE);
    }    

    function index()
    {    
        $data = array();
        $data['tab_data'] = $this->holiday->get_tab_data();
        $data['mainContent'] = $this->load->view('holiday/holiday', $data, TRUE);
        $this->load->view('index', $data);
    }

    function package_details($id)
    {
        $data = array();
        $data['package_details'] = $this->holiday->get_package_details($id);
        $data['mainContent'] = $this->load->view('holiday/package_details', $data, TRUE);
        $this->load->view('index', $data);
    }
    
    function send_query($id)
    {
        global $data;
        $data['pack_details'] = $this->holiday->get_package_name($id);
                $data['mainContent'] = $this->load->view('holiday/send_query', $data, true);;
        $this->load->view('index', $data);
    }
    
    function confirm()
    {
        $data = array();
// here $_SESSION['alternate_reff']; // here it's not print reference number which define
// the reference number in the booking_confirmation() method
        $data['mainContent'] = $this->load->view('holiday/confirmation', $data, true);
        $this->load->view('index', $data);    
    }
    
        function booking_confirmation()
    {
                global $data;
                $reff = array();
                $id = $this->uri->segment(4);
                $url = base64_decode($this->uri->segment(5));
        
        $reff = $this->holiday->check_reff_num();
                    if($reff['count_id'] == 0)
                        $data['reference_no'] = 'HA00000A';
                    else
                    {
                        $final_reff = $this->holiday->get_reff_num($reff['max_id']);
                        $final_reff = substr($final_reff, 1);
                        $data['reference_no'] = 'H'.generate_reference($final_reff);
                    }
                
        $data['package_id'] = $id;
        $data['package_url'] = $url;
        $data['departure_date'] = $this->input->post('departure_date', TRUE);
                if($data['departure_date'])
                {
                $from = split("/", $data['departure_date']);
        $data['departure_date'] = $from[2]."-".$from[0]."-".$from[1] ;
                }
                
        $data['first_name'] = $this->input->post('fname', TRUE);
        $data['last_name'] = $this->input->post('lname', TRUE);
        $data['email'] = $this->input->post('email', TRUE);

        $result = $this->holiday->save_tourist_info($data);
        $_SESSION['alternate_reff']= $data['reference_no'];
// echo $_SESSION['alternate_reff']; // here its print the reference no
// but view page its not showing the reference number

                if($result)
                {
                    $reff_num = array
                    (
                      'reference_no' => $data['reference_no'],
                      'save_reference' => 'ok'
                    );
                    $this->session->set_userdata($reff_num);
                }
        redirect('user/holiday/confirm');
    }
}
?>



// view page confirmation.php
<?php
    /*
      if($this->session->userdata('save_reference') == 'ok')
      echo $this->session->userdata('reference_no');
      // this codeigniter session code is  working
    */
?>
<div>
    <div style="font-weight:bold" class="text_font">
            Thank you for your interest in our holiday package.
    </div><br>

    &lt;?php if($_SESSION['save_reference'] != '') {?&gt;
    <div class="text_font">
            Your Booking Reference Number is:<B>
          &lt;?php
               // this line is not working..i mean not showing the reference number
               echo $_SESSION['reference_no'];?&gt;</B>.
    </div><br>
    &lt;?php } ?&gt;

    <div class="text_font">
            A TravelmartBD.com holiday executive will contact with you very soon with the information you need.
    </div>
    
</div>

// please help
// there is any rules for using php native session with codeigniter 1.7.2
// in my config file $config['sess_encrypt_cookie']= FALSE; // not saving session data
#2

[eluser]ranjitbd[/eluser]
Code:
sorry, i didnt session_start() in my controller.




Theme © iAndrew 2016 - Forum software by © MyBB