Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
853 views
in Technique[技术] by (71.8m points)

post data via redirect function in codeigniter

Is there ever a way or some tricks to post an array of data or a single variable string data using redirect() function in codeiginter?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

when using redirect you go from one controller or another by this process all post data are destroyed unless you stored them on a session, here is how i do it

$data = array('firstname'=>'fname','lastname'=>'lastname');
// i store data to flashdata
$this->session->set_flashdata('lolwut',$data);
// after storing i redirect it to the controller
redirect('controller/method')

so on your redirected controller you can access it via $this->session->flashdata('lolwut') note that i am using flashdata not userdata, flashdata destroys itself on the next process.

read more flashdata here SESSION CLASS


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...