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


PHP UserSession::create方法代码示例

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


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

示例1: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     try {
         $Customer = new CustomerModel();
         $verifEmail = $Customer->sameMail($formFields['Email']);
         if ($verifEmail && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && $formFields['password2'] == $formFields['password'] && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
             $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
             //var_dump($Birthdate);
             $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
             //var_dump($Customer_id);
             $user = $Customer->findCustomer($Customer_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('');
         } else {
             $http->redirectTo('Exception?Error=3');
         }
     } catch (DomainException $event) {
         $form = new RegisterForm();
         $form->bind($formFields);
         $form->setErrorMessage($event->getMessage());
         return ['_form' => $form];
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:30,代码来源:UserController.class.php

示例2: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     /*
      * Méthode appelée en cas de requête HTTP POST
      *
      * L'argument $http est un objet permettant de faire des redirections etc.
      * L'argument $formFields contient l'équivalent de $_POST en PHP natif.
      */
     $Customer = new CustomerModel();
     $verifEmail = $Customer->sameMail($formFields['Email']);
     //var_dump(strlen($_POST['Phone']));
     //var_dump(strlen($_POST['ZipCode']));
     if ($verifEmail['result'] === '0' && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) {
         $password = password_hash($formFields['password'], PASSWORD_DEFAULT);
         //var_dump($password);
         $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day'];
         //var_dump($Birthdate);
         $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']);
         //var_dump($Customer_id);
         $user = $Customer->findCustomer($Customer_id);
         $UserSession = new UserSession();
         $UserSession->create($user);
         $http->redirectTo('');
     } elseif ($verifEmail != '0') {
         $http->redirectTo('Exception?Error=3');
     }
 }
开发者ID:annacrea,项目名称:ChezPaolo,代码行数:27,代码来源:UserController.class.php

示例3: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) {
         $CustomerModel = new CustomerModel();
         $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password']);
         //var_dump($user_id);
         if (ctype_digit($user_id)) {
             $user = $CustomerModel->findCustomer($user_id);
             $UserSession = new UserSession();
             $UserSession->create($user);
             $http->redirectTo('/');
         } else {
             $http->redirectTo('Exception?' . $user_id);
         }
     } else {
         $http->redirectTo('Exception?Error=4');
     }
 }
开发者ID:annacrea,项目名称:ChezPaolo,代码行数:18,代码来源:LoginController.class.php

示例4: httpPostMethod

 public function httpPostMethod(Http $http, array $formFields)
 {
     if (filter_var($formFields['Login'], FILTER_VALIDATE_EMAIL) != false) {
         try {
             $userSession = new UserSession();
             $CustomerModel = new CustomerModel();
             $user_id = $CustomerModel->findWithCredentials($formFields['Login'], $formFields['Password'], $_SERVER['REMOTE_ADDR']);
             if (ctype_digit($user_id)) {
                 $user = $CustomerModel->findCustomer($user_id);
                 $userSession->create($user);
                 $http->redirectTo('/');
             }
         } catch (DomainException $event) {
             //var_dump($event);
             $form = new LoginForm();
             $form->bind($formFields);
             $form->setErrorMessage($event->getMessage());
             return ['_form' => $form];
             //AVEC CONTROLEUR EXECPTION --- $http->redirectTo('Exception?'.$user_id);
         }
     } else {
         $http->redirectTo('Exception?Error=4');
     }
 }
开发者ID:paolocl,项目名称:ChezPaolo,代码行数:24,代码来源:LoginController.class.php

示例5: connect

 /**
  * @return User
  */
 public static function connect($username, $remember)
 {
     if (User::find_by_username($username)) {
         $sessid = md5(uniqid());
         $expiration = $remember ? Utils::tps() + 365 * 86400 : Utils::tps() + 24 * 3600;
         $user = User::find_by_username($username);
         UserSession::create(array('user_id' => $user->id, 'session_id' => $sessid, 'expiration' => $expiration, 'remember' => $remember));
         setcookie('SESSID', $sessid, $expiration);
         return $user;
     }
 }
开发者ID:agiza,项目名称:DreamVids,代码行数:14,代码来源:user.php


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