0

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);
}
2
1

This should do it:

$redirect = new TrustedRedirectResponse($url);
return $redirect->send();
0

Your Answer

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