本文整理汇总了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];
}
}
示例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');
}
}
示例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');
}
}
示例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');
}
}
示例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;
}
}