I have an odd situation. consider the following scenario:
- form on page posts to another domain
- that domain processes data, and posts back to controller A
- controller A processes returned data, and sets flash session vars
- controller A redirects to controller B
- session values set in controller A are lost.
Now, I have noticed that if I eliminate step 4; the session values
are not lost. It is only happening after calling Response::redirect().
Following is the relevant code in controller A's post handler (in
this case, $vars is set to Input::post(); and the renew() method does a
soap call to another API, and returns response data.):
$success_object = $this->renew( $vars );
$persist_through_redirect = array(
'accountId' => $success_object->account->accountId,
'expireDate' => $success_object->account->expireDate,
'createDate' => $success_object->account->createDate,
'due_amount' => $success_object->account->lastPaymentAmt,
'offer_name' => $offer_name,
'member_name' => $vars['first_name'] . ' ' . $vars['last_name']
);
return $this->redirect('success/', $persist_through_redirect);
And this is the code behind method redirect():
private function redirect($redirect_endpoint, $redirect_values = null) {
Session::set_flash('flash_redirect', $redirect_values);
Response::redirect($redirect_endpoint);
}
Finally, here is the code in controller B that accesses the session data:
$information = Session::get_flash('flash_redirect');
if(isset($information)) {
View::set_global('membership', $information);
}
// set the locale based on fuel's setting
View::set_global('locale', str_replace( '_', '-', Fuel::$locale ));
return View::forge('successes/success_card');
It gets weirder though. Not all session data is lost. Any session data I had set in the before() method is staying put. It is also worth mentioning that whether I use set() or set_flash(), I have the same result
I'm very stumped on this one. Any ideas why my session data is lost? I don't think it has anything to do with posting to the other domain (since there are conditions where the redirect will not happen, and in those cases the session vars are still there as well), but who knows? So far Fuel has been very kind to me, until this. :P
EDIT: I also forgot to mention that SOME session vars are kept. There is one session value that gets set in the before() controller method; and that one seems to stick regardless of redirect or not.