当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::clear方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Session::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::clear方法的具体用法?PHP Session::clear怎么用?PHP Session::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Session\Session的用法示例。


在下文中一共展示了Session::clear方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginProcessAction

 public function loginProcessAction()
 {
     $userId = $this->get("request")->request->get("user_id");
     $em = $this->getDoctrine()->getManager();
     $session = new Session();
     $session->clear();
     $session->start();
     if (strpos($userId, "teacher") != 0) {
         $userId = str_replace("_teacher_", "", $userId);
         $teacher = $em->getRepository("sociaLecompsSuperBundle:Teacher")->find($userId);
         $session->set("user_id", $teacher->getId());
         $session->set("name", $teacher->getName());
         $session->set("last_name", $teacher->getLastName());
         $session->set("privilege", "teacher");
         return $this->redirect($this->generateUrl("socia_lecomps_teacher_homepage"));
     } else {
         $userId = str_replace("_student_", "", $userId);
         $student = $em->getRepository("sociaLecompsSuperBundle:Student")->find($userId);
         $session->set("user_id", $student->getId());
         $session->set("name", $student->getName());
         $session->set("last_name", $student->getLastName());
         $session->set("privilege", "student");
         return $this->redirect($this->generateUrl("socia_lecomps_student_homepage"));
     }
 }
开发者ID:esseara,项目名称:lecomps,代码行数:25,代码来源:DefaultController.php

示例2: doLogout

 /**
  * Perform the logout, resetting the session
  */
 public function doLogout()
 {
     $this->deleteRememberMeCookie();
     $this->session->clear();
     $this->session->invalidate();
     $this->user_is_logged_in = false;
 }
开发者ID:khaidir,项目名称:phpservermon,代码行数:10,代码来源:User.class.php

示例3: logoutAction

 public function logoutAction()
 {
     $session = new Session();
     $session->clear();
     $url = $this->generateUrl("glpmr_authentification_homepage");
     return $this->redirect($url);
 }
开发者ID:JDemonchaux,项目名称:glpmr-portail,代码行数:7,代码来源:AuthentificationController.php

示例4: logout

 public function logout()
 {
     $session = new Session();
     if ($session->has('steamID')) {
         $session->clear();
     }
     return view("csgo/index")->with('session', $session);
 }
开发者ID:stefanstankovic,项目名称:CSGO_project,代码行数:8,代码来源:CSGoController.php

示例5: displayAction

 /**
  * @Route("/zarzadzaj-kontem-biuro-podrozy", name="account")
  */
 public function displayAction(Request $request)
 {
     $session = new Session();
     $konto = $this->getDoctrine()->getRepository('AppBundle:Konto')->findOneByLogin($session->get('name'));
     if ($request->getMethod() == 'POST') {
         $session->clear();
         return $this->redirectToRoute('homepage');
     }
     return $this->render('default/account.html.twig', array('konto' => $konto, 'session' => $session, 'base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..')));
 }
开发者ID:Elleander,项目名称:BiuroPodrozyProject,代码行数:13,代码来源:AccountController.php

示例6: CustomerRegisterAction

 /**
  * @Route("/customer-register",name="customer-register")
  */
 public function CustomerRegisterAction(Request $request)
 {
     $userConnect = $request->getSession()->get('user');
     $bdd = $this->getDoctrine();
     $user = new User();
     $form = $this->createFormBuilder($user)->add('email', EmailType::class, array('label' => 'Email', 'required' => true, 'attr' => array('class' => 'form-control')))->add('password', PasswordType::class, array('label' => 'Mot de passe', 'required' => true, 'attr' => array('class' => 'form-control')))->add('connect', SubmitType::class, array('label' => 'Se Connecter', 'attr' => array('class' => 'btn btn-template-main')))->getForm();
     $register = $this->createFormBuilder($user)->add('nom', TextType::class, array('label' => 'Nom', 'required' => true, 'attr' => array('class' => 'form-control')))->add('prenom', TextType::class, array('label' => 'Prénom', 'required' => true, 'attr' => array('class' => 'form-control')))->add('login', TextType::class, array('label' => 'Choose a login', 'required' => true, 'attr' => array('class' => 'form-control')))->add('dateNaissance', BirthdayType::class, array('label' => 'Date de naissance', 'required' => true, 'years' => range(1900, 1998), 'format' => 'ddMMyyyy'))->add('password', RepeatedType::class, array('type' => PasswordType::class, 'invalid_message' => 'Les deux champs doivent correspondre.', 'options' => array('attr' => array('class' => 'form-control')), 'required' => true, 'first_options' => array('label' => 'Password'), 'second_options' => array('label' => 'Repetez le  Password')))->add('email', EmailType::class, array('label' => 'Email', 'required' => true, 'attr' => array('class' => 'form-control')))->add('charte', CheckboxType::class, array('label' => 'J\'ai lu et j\'accepte les conditions de la charte de bonne conduite.', 'required' => true, 'attr' => array('class' => 'checkbox-inline')))->add('regist', SubmitType::class, array('label' => 'S\'enregistrer', 'attr' => array('class' => 'btn btn-template-main')))->getForm();
     $form->handleRequest($request);
     $register->handleRequest($request);
     if ($register->isSubmitted() && $register->isValid()) {
         if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) {
             $salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22);
             $user->setPassword(crypt($register->getData()->getPassword(), $salt));
         }
         $role = $bdd->getRepository('AppBundle:Role')->findOneById(2);
         $user->setRole($role);
         $em = $bdd->getManager();
         $em->persist($user);
         $em->flush();
         $this->addFlash('success', 'Votre inscription a bien été prise en compte.');
     }
     if ($form->isSubmitted() && $form->isValid()) {
         $userToLog = $bdd->getRepository('AppBundle:User')->findOneByEmail($form->getData()->getEmail());
         if ($userToLog) {
             if (crypt($form->getData()->getPassword(), $userToLog->getPassword()) == $userToLog->getPassword()) {
                 //route a definir
                 $session = new Session();
                 $session->clear();
                 $session->start();
                 $session->set('user', $userToLog);
                 //                    var_dump($userToLog->getRoles()->getId());
                 if ($userToLog->getRoles()->getId() == 1) {
                     return $this->redirectToRoute('dashboard');
                 } else {
                     return $this->redirectToRoute('homepage');
                 }
             } else {
                 $form->get('password')->addError(new FormError('Le mot de passe est incorrect.'));
             }
         } else {
             $form->get('email')->addError(new FormError('Email inconnu'));
         }
     }
     //
     return $this->render('@App/front/customer-register.html.twig', array('base_dir' => realpath($this->container->getParameter('kernel.root_dir') . '/..'), 'nav_active' => 'connexion', 'form' => $form->createView(), 'register' => $register->createView(), 'user' => $userConnect));
 }
开发者ID:FlashParking,项目名称:flashparkingweb,代码行数:49,代码来源:CustomerRegisterController.php

示例7: getDiffs

 /**
  * @param Request|null      $request
  * @param array|string|null $selectedClassName
  * @param array             $specimensWithChoices
  * @param array             $choicesToRemove
  * @return array
  */
 public function getDiffs(Request $request = null, $selectedClassName = null, $specimensWithChoices = [], $choicesToRemove = [])
 {
     $classesName = [];
     if (is_string($selectedClassName) && $selectedClassName != 'all') {
         $classesName = [$selectedClassName];
     }
     if (is_array($selectedClassName)) {
         $classesName = $selectedClassName;
     }
     if (!is_null($request) && !is_null($request->query->get('reset', null))) {
         $this->sessionManager->clear();
     }
     $allDiffs = $this->sessionManager->get('diffs');
     $diffs = $this->diffHandler->getDiffsFile()->filterResults($allDiffs, $classesName, $specimensWithChoices, $choicesToRemove);
     $diffs['selectedSpecimens'] = $this->sessionManager->get('selectedSpecimens', []);
     return self::orderDiffsByTaxon($diffs);
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:24,代码来源:ExportManager.php

示例8: clearSession

 /**
  * Clear Session
  */
 private function clearSession(Session $session)
 {
     if ($session->isStarted()) {
         $session->clear();
     }
 }
开发者ID:professor93,项目名称:mobicms,代码行数:9,代码来源:Logout.php

示例9: logoutAction

 public function logoutAction(Request $request)
 {
     $session = new Session();
     $session->clear();
     return $this->render('LoginLoginBundle:Pages:login.html.twig');
 }
开发者ID:pembrock,项目名称:hotel,代码行数:6,代码来源:DefaultController.php

示例10: resultAction

 /**
  * @Route("/quiz/result", name="result")
  */
 public function resultAction()
 {
     $session = new Session();
     $allQuestions = (int) $session->get('countOfAllAnswers');
     $rightAnswers = (int) $session->get('countOfRightAnswers');
     $startTimestamp = $session->get('startTime');
     $startTime = new \DateTime();
     $startTime->setTimestamp($startTimestamp);
     $currentTime = new \DateTime();
     $result['answers'] = $allQuestions ? number_format($rightAnswers * 100 / $allQuestions, 1) : 0;
     $result['time'] = $currentTime->diff($startTime)->format('%hh:%im:%ss');
     $session->clear();
     return $this->render('default/result.html.twig', array('result' => $result));
 }
开发者ID:repsa,项目名称:quiz,代码行数:17,代码来源:DefaultController.php

示例11: createPageMessages

 /**
  * Erstellen der Übersichtsseite der Ladevorgängen
  *
  * @param array $global
  *
  * @return html Ausgabe
  */
 public function createPageMessages($global)
 {
     $session_filter = new Session();
     $session_filter->start();
     $session_filter->clear();
     // Session löschen beim Seiten neu laden!
     $users = $this->getDoctrine()->getRepository('SteveFrontendBundle:User')->findAll();
     $chargeboxes = $this->getDoctrine()->getRepository('SteveFrontendBundle:Chargebox')->findAll();
     $log = $this->getDoctrine()->getRepository('SteveFrontendBundle:Log')->findBy(array(), array('id' => "desc"));
     $array_render = array('log' => $log, 'users' => $users, 'chargeboxes' => $chargeboxes, 'global' => $global);
     if ($this->container->getParameter('kernel.environment') == "dev") {
         dump($log);
     }
     return $this->render('SteveFrontendBundle:Default:messages.html.twig', $array_render);
 }
开发者ID:patudd,项目名称:SteVeFui,代码行数:22,代码来源:OutputController.php

示例12: logoutAction

 public function logoutAction()
 {
     $session = new Session();
     $session->clear();
     return $this->redirect($this->generateUrl('fontend_homepage'));
 }
开发者ID:pranabumal,项目名称:loginproject-symfony,代码行数:6,代码来源:DefaultController.php


注:本文中的Symfony\Component\HttpFoundation\Session\Session::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。