symfony 3でかなり新しくなっているので、ユーザーがログインしてログアウトするときにどうすればいいのですか...私は時間のエンティティを作成する必要があります。 id、userID startTime、endTime ..があり、ユーザーはこのエンティティとの接続(多くの場合、多くのユーザーがたくさんのログインを持つことができます)を持っている必要があります。この情報をデータベースに保存したいのですが。私はGoogleで検索しようとしましたが、共通点は何も見つかりませんでした。私は、コントローラsymfony 3回ログインしてログアウトするとき
@Route("/login", name="authentication_login")
public function loginActionAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('AppBundle:uzduotis:login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
にこのボタンを に ログイン を押された時間のstartTimeとコードをアクティブにしたいと思います
は、endTimeはこの答えのために
/**
* @Route("/logout", name="logout")
* @Method({"GET"})
*/
public function logoutAction(Request $request)
{
$session = $this->$request->getSession();
$session = $this->get('session')->clear();
return $this->render('AppBundle:uzduotis:login.html.twig');
}