How do I redirect to my site's homepage after my site times-out?

て烟熏妆下的殇ゞ 提交于 2019-12-11 14:58:19

问题


Without modifying the Symfony code, I want my site to automatically redirect the user to my site's homepage and display a message that the user's session has timed out. Currently, when the time-out occurs the user's browser is automatically redirected to a confusing Symfony error that says:

Cannot redirect to an empty URL. 500 Internal Server Error - InvalidArgumentException

Stack Trace 1. in vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/RedirectResponse.php at line 76 - public function setTargetUrl($url) { if (empty($url)) { throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); } $this->targetUrl = $url;

  1. at RedirectResponse ->setTargetUrl ('') in vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/RedirectResponse.php at line 39

  2. at RedirectResponse ->__construct ('', '302') in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 82

  3. at Controller ->redirect ('') in src/AppBundle/Controller/BreakinOutBoardController.php at line 5436 +

  4. at XXXXXXXController ->myVideosAction (null)

  5. at call_user_func_array (array(object(XXXXXXXXController), 'myVideosAction'), array(null)) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 142

  6. at HttpKernel ->handleRaw (object(Request), '1') in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 62

  7. at HttpKernel ->handle (object(Request), '1', true) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php at line 67

  8. at ContainerAwareHttpKernel ->handle (object(Request), '1', true) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 183

  9. at Kernel ->handle (object(Request)) in web/app_dev.php at line 31

Logs - 1 error

  1. INFO - Matched route "app_breakinoutboard_myvideos".

  2. INFO - Populated the TokenStorage with an anonymous Token.

  3. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".

  4. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".

  5. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".

  6. DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".

  7. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest".

  8. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".

  9. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".

  10. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest".

  11. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest".

  12. DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".

  13. DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".

  14. DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController".

  15. DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController".

  16. DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController".

  17. DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController".

  18. DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController".

  19. INFO - The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the request instead.

  20. INFO - The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the request instead.

  21. INFO - The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the request instead.

  22. CRITICAL - Uncaught PHP Exception InvalidArgumentException: "Cannot redirect to an empty URL." at /var/www/vhosts/symfony2/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/RedirectResponse.php line 76

  23. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".

  24. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".

  25. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".

  26. DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".

  27. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest".

  28. DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".

来源:https://stackoverflow.com/questions/56625363/how-do-i-redirect-to-my-sites-homepage-after-my-site-times-out

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!