1

How do you pass array data with a redirect function in Codeigniter?

I've passed an array but in URL print base url/controller/Array. in My Controller.

 function getDefaultValue()
 {
     $dataArr=stateData();
     /*$dataArr array */ 
     redirect('home/'$dataArr);

 }
1
  • 1
    No, you can use flashdata (storage in cookies/session/database) that last "one" reload. Commented Apr 19, 2014 at 9:03

2 Answers 2

2

As of my comment, here is an example:

function getDefaultValue()
{
    $dataArr=stateData();
    /*$dataArr array */ 
    $this->session->set_flashdata('my_super_array', $dataArr);
    redirect('home/'$dataArr);
}

and retrieve data as following

$this->session->flashdata('my_super_array');

You can find more here.

Sign up to request clarification or add additional context in comments.

Comments

1

Set your data in session and access that session on another page.

$dataArr=stateData();
$this->session->set_userdata("dataArr",$dataArr);
$this->session->userdata("dataArr");

after your work complition unset that session key

$this->session->unset_userdata("dataArr");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.