[eluser]boltsabre[/eluser]
As mentioned above:
- redirect() is CI based, not a native PHP function.
- it sends the user to a completely new URL by setting a php based Location header.
- because http is a stateless environment, this means that any variables, class instantiations, etc, are lost after performing a http redirect. You are effectively starting afresh.
- So... to pass data from on controller, to another controller, you need to store it somewhere before you do the redirect(), and then retrieve it after the redirect.
- The 4 most common methods, in CI, in my preferred order, for this scenario, are: flashdata, sessiondata, cookie, database.
Flashdata is best, because you set it before the redirect, retrieve it after the redirect, and then it's gone, you don't have to worry about unsetting/deleting it or anything, it's own "garbage disposal" handles all this for you.