내가하고 싶은 것은 누군가 쿠키가 있다면 로그인했는지 확인하는 것이다. 그들이 가지고있을 때 $cookie_data/dashboard
으로 리디렉션하고 싶습니다.로그인 후 리다이렉트 succes + Silex
내 서버에서 언어를 선택하면 쿠키가 설정되기 때문에. 그래서 $language/dashboard
으로 리디렉션하고 싶습니다.
$app['security.authentication.success_handler.secured_area'] = $app->share(function() use ($app) {
$request = $app['request'];
$cookies = $request->cookies;
if($cookies->has("language"))
{
return $app->redirect('/nl/dashboard');
}
});
를하지만 나에게 오류를 제공합니다 :
지금이
Warning: array_map(): An error occurred while invoking the map callback in /Applications/MAMP/htdocs/pst/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php on line 264
Fatal error: Uncaught exception 'RuntimeException' with message 'Accessed request service outside of request scope. Try moving that call to a before handler or controller.' in /Applications/MAMP/htdocs/pst/vendor/silex/silex/src/Silex/Application.php:141 Stack trace: #0 /Applications/MAMP/htdocs/pst/vendor/pimple/pimple/lib/Pimple.php(83): Silex\Application->Silex\{closure}(Object(Silex\Application)) #1 /Applications/MAMP/htdocs/pst/app/bootstrap.php(67): Pimple->offsetGet('request') #2 /Applications/MAMP/htdocs/pst/vendor/pimple/pimple/lib/Pimple.php(126): {closure}(Object(Silex\Application)) #3 /Applications/MAMP/htdocs/pst/vendor/pimple/pimple/lib/Pimple.php(83): Pimple::{closure}(Object(Silex\Application)) #4 /Applications/MAMP/htdocs/pst/vendor/silex/silex/src/Silex/Provider/SecurityServiceProvider.php(409): Pimple->offsetGet('security.authen...') #5 /Applications/MAMP/htdocs/pst/vendor/pimple/pimple/lib/Pimple.php(126): Silex\Provider\SecurityServiceProvider->Silex\Provider\{closure}(Object(Silex\Application)) #6 /A in /Applications/MAMP/htdocs/pst/vendor/silex/silex/src/Silex/Application.php on line 141
가 어떻게이 일을하거나 가장 좋은 방법은 무엇입니까?