deal with dates correctly

This commit is contained in:
Thomas Rubini 2023-01-26 20:10:11 +01:00
parent e04b43f0ad
commit 2f4128beeb
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,10 @@ ini_set("session.cookie_lifetime", $__SESSION_TIMEOUT);
final class UserController
{
private static function currentDate(){
return date("Y-m-d H:i:s");
}
public function loginAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
{
if (Session::is_login()) {
@ -53,6 +57,9 @@ final class UserController
return header("Location: /user/login");
}
$O_user->S_LAST_SEEN = self::currentDate();
$O_user->update();
Session::set_login($O_user->I_ID);
self::redirectToPreviousPage($A_postParams);

View File

@ -45,10 +45,11 @@ final class UserModel extends UserSessionModel
public function insert(){
$O_model = Model::get();
$stmt = $O_model->prepare("INSERT INTO USER (EMAIL, USERNAME, PASS_HASH, FIRST_SEEN) VALUES(:email, :username, :password_hash, :first_seen)");
$stmt = $O_model->prepare("INSERT INTO USER (EMAIL, USERNAME, PASS_HASH, FIRST_SEEN, LAST_SEEN) VALUES(:email, :username, :password_hash, :first_seen, :last_seen)");
$stmt->bindParam("email", $this->S_EMAIL);
$stmt->bindParam("username", $this->S_USERNAME);
$stmt->bindParam("password_hash", $this->S_PASSWORD_HASH);
$stmt->bindParam("last_seen", $this->S_LAST_SEEN);
$stmt->bindParam("first_seen", $this->S_FIRST_SEEN);
$stmt->execute();
$this->I_ID = Model::get()->lastInsertId();