如何将视图中发送的数据存储到CI中的控制器

I have a big string data send from view to controller. The string may exceed 65535 characters. I've tried to store it in session flash data.

This is my method in controller to store the data

public function get_dt_pemenuhan_d2(){
   $this->load->library('session');

   $list = $this->input->post('no_pnh'); //a huge list of item

   $this->session->set_flashdata('sess_no_pnh',$list);
}

and this is my method to retrieve the data from the session flashdata

public function pembebanan2(){
    $this->load->library('session');

    $get_no_pnh = $this->session->flashdata('sess_no_pnh');
    $data       = array('no_pnh' => $get_no_pnh);

    $this->load->view('memo_pembebanan2',$data); //sending the data to a view
}

Everything is fine for a small data (less than 500 chars). But if I store a huge data, nothing is sent to the view. I've used alert to make sure all the data completely sent to the controller and it's all good. So, what's wrong in the code?

Any help and suggestions are greatly appreciated. Thank you

Edit : this is the view and how i post the data to controller and later view it in a pop up view

$("#btn_memo").on('click',function(e){
   var arr_pnh = [];
   $('#tbl_content tr td:nth-child(2)').each(function(){ 
      var x = $(this).text().split('||');
      arr_pnh.push(x[1]);
   });

   var no_pnh = arr_pnh;

   $.post('<?php echo site_url('con_atk/get_dt_pemenuhan_d2'); ?>',{no_pnh:no_pnh},function(){

       popUp = new Boxy("<iframe src='<?php echo site_url('con_atk/pembebanan2') ?>' width='640px' height='480px' frameborder='0'></iframe>" , {title: "<strong>Memo Pembebanan</strong>" , modal: true});
   });
});

And this is the view:

<div id="div_tbl_body">
            <table id="tbl_content" width="100%" class="table table-bordered" cellspacing="0" cellpadding="0">  
            <thead>
                <tr>
                    <th style="width:4%;  text-align:right">No</th>
                    <th style="width:32%; text-align:center">Names</th> 
                </tr>
            </thead>
            <tbody>
            //"<tr><td>"+ no++ +"</td>";<!-- This is generated by AJAX-->
            //    "<td align='center'>"+ id +"<font size='1px' color='#FFFFFF'>||"+no_pnh+"</font></td></tr>";<!-- This is generated by AJAX-->
            </tbody>
            </table>
        </div> 

My question is why I could not store huge sata in the session? are there any option to store huge data in controller and can be accessed by the method except using session?

EDIT: After researching, I have found a suggestion and most likely may work.

I saw that sessions have a limited size, and also, even cookies.

The best way for you to do it is to get the data, store it in a database, get in from your model into your controller, and then pass it to the popup.

Your next option would be storing it into a .txt file then loading it from there.

EDIT: Here is something you can do.

Post the data do a controller, instead of doing this

public function get_dt_pemenuhan_d2(){
$this->load->library('session');

$list = $this->input->post('no_pnh'); //a huge list of item

$this->session->set_flashdata('sess_no_pnh',$list); 
}

Do this

public function get_dt_pemenuha_d2()
{
    $this->load->model('your_model');
    $list = $this-input->post('no_pnh');
    $this->your_model->insert_into_table($list);
 }

This would be your model function

public function insert_into_table($list)
{
    $this->db->insert('table_name',$list);
}

then if you want to access it just do this

public function pembebanan2()
{
    $this->load->model('your_model');
    $data['list'] = $this->your_model->get_list();
    $this->load->view('memo_pembebanan2',$data);
}

this is your get_list function

public function get_list()
{
  $this->db->get('yourtable');
}

you can just delete the inside of the table if you want after it's done or put an ID to be able to use a where clause if you want to keep others lists.

No need to make it into a global variable, just load your model and get your list

now in your view you just need to echo that $list

Maybe just try to compress data using gzencode

sth like that:

$this->session->set_flashdata('sess_no_pnh', gzencode($list));

or just store it in a temp file, and keep reference into session:

$tmpfname = tempnam("/tmp", "FOO");
$handle = fopen($tmpfname, "w");
fwrite($handle, $list);
fclose($handle);
$this->session->set_flashdata('sess_no_pnh', $tmpfname);

and then just read it in popup:

$get_no_pnh = $this->session->flashdata('sess_no_pnh');
$data       = array('no_pnh' => file_get_contents($get_no_pnh));
unlink($get_no_pnh);