Is it possible to redirect users from a controller?

I tried using the following code, but it doesn't work.

public function hello() {
  $query = $db->select('coop.oad','x');
  $query->fields('x', ['oad_url']);
  $query->condition('x.oad_soc', $column_name,'=');
  $result = $query->execute()->fetchField();

  return new TrustedRedirectResponse($result);

This should do it:

$redirect = new TrustedRedirectResponse($url);
return $redirect->send();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.