From 924ce2261ac2856e6fc18b5f8d66707635aa7aef Mon Sep 17 00:00:00 2001 From: arsaizdihar <arsadihar@gmail.com> Date: Thu, 16 Nov 2023 17:59:26 +0700 Subject: [PATCH] feat: change session config --- Dockerfile.build | 2 +- src/Views/register.php | 7 +++---- src/public/index.php | 6 +++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile.build b/Dockerfile.build index 7cd0bb7..2b2631d 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -4,7 +4,7 @@ RUN apt-get install -y libpq-dev -y libxml2-dev RUN docker-php-ext-install pdo pdo_pgsql soap RUN a2enmod rewrite COPY ./src /var/www/html -RUN mkdir /var/www/html/public/media +RUN mkdir -p /var/www/html/public/media RUN chown -R www-data:www-data /var/www/html/public RUN chmod -R 777 /var/www/html/public COPY ./src/php.ini /usr/local/etc/php/php.ini \ No newline at end of file diff --git a/src/Views/register.php b/src/Views/register.php index 293bad6..bdc7a41 100644 --- a/src/Views/register.php +++ b/src/Views/register.php @@ -2,7 +2,7 @@ <h1 class="auth-title">Register</h1> <div class="input-group"> <label for="name" class="required">Nama</label> - <input name="name" autofocus placeholder="Nama" value="<?= htmlspecialchars($fields["name"]) ?>" /> + <input name="name" autofocus placeholder="Nama" value="<?= htmlspecialchars($fields["name"] ?? "") ?>" /> <?php if (array_key_exists('name', $errors)) { echo '<div class="error">' . $errors["name"] . '</div>'; @@ -11,7 +11,7 @@ </div> <div class="input-group"> <label for="email" class="required">Email</label> - <input name="email" type="email" autofocus placeholder="Email" value="<?= htmlspecialchars($fields["email"]) ?>" /> + <input name="email" type="email" autofocus placeholder="Email" value="<?= htmlspecialchars($fields["email"] ?? "") ?>" /> <?php if (array_key_exists('email', $errors)) { echo '<div class="error">' . $errors["email"] . '</div>'; @@ -20,8 +20,7 @@ </div> <div class="input-group"> <label for="phone_number">No Telepon</label> - <input name="phone_number" type="tel" placeholder="No Telepon" - value="<?= htmlspecialchars($fields["phone_number"]) ?>" /> + <input name="phone_number" type="tel" placeholder="No Telepon" value="<?= htmlspecialchars($fields["phone_number"] ?? "") ?>" /> <?php if (array_key_exists('phone_number', $errors)) { echo '<div class="error">' . $errors["phone_number"] . '</div>'; diff --git a/src/public/index.php b/src/public/index.php index 9276b5a..a07f837 100644 --- a/src/public/index.php +++ b/src/public/index.php @@ -27,7 +27,11 @@ if (!defined('AUTOLOAD')) { use app\Core\Application; $uri = $_SERVER['REQUEST_URI']; -session_start(); +session_start([ + "cookie_httponly" => true, + "cookie_secure" => true, + "cookie_lifetime" => 1000 * 60 * 60 * 24 * 30, +]); $app = new Application(); $app->run(); -- GitLab