Undefined variable: user in view on line 60 NULL Phalcon

212 Views Asked by At

I'm trying to pass an array in redirect to another page but it say undefined variable user

return $this->response->redirect($this->MyHelper->Route('eb-user-verify-reset-password-code'), $User->toArray());

How can I access $user->toArray() in the redirected page?

I try to recive it like <?php var_dump($user);?> in my new page but it's throwing the below error:

Undefined variable: user in view on line 60 NULL Phalcon

Details:

I'm passing user details via redirect function to another page. So in the redirect I'm passing the user details as second param. But I'm getting error in the page where I want to receive the user details array.

1

There are 1 best solutions below

2
Talal On

Phalcon\Http\Response::redirect() will redirect using http and you can't pass any data unless using POST, GET, etc

if you asking for another way to redirect with parameters you can use Phalcon\Mvc\Dispatcher::forward()

example:

$this->dispatcher->forward(
    [
        'controller' => 'posts',
        'action' => 'search',
        'params' => [1, 2, 3]
    ]
);

refer to the documentation for more info https://docs.phalconphp.com/3.4/en/dispatcher#forwarding