summaryrefslogtreecommitdiff
path: root/signup
diff options
context:
space:
mode:
Diffstat (limited to 'signup')
-rwxr-xr-xsignup/signup.php12
-rwxr-xr-xsignup/verify/verify.php6
2 files changed, 10 insertions, 8 deletions
diff --git a/signup/signup.php b/signup/signup.php
index 5ba3ca8..4300b61 100755
--- a/signup/signup.php
+++ b/signup/signup.php
@@ -17,6 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+define('ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/');
+
+require_once ROOT . '/php/session.php';
+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
@@ -64,13 +68,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$user_id = $pdo->lastInsertId();
- setcookie('user_id', (string)$user_id, [
- 'expires' => 2147483647,
- 'path' => '/',
- 'secure' => true,
- 'httponly' => true,
- 'samesite' => 'Strict'
- ]);
+ set_user_id((int)$user_id);
} catch (\PDOException $e) {
if ($e->getCode() == 23000) {
echo "Error: Username or email is already taken.";
diff --git a/signup/verify/verify.php b/signup/verify/verify.php
index e5e729f..1fc6202 100755
--- a/signup/verify/verify.php
+++ b/signup/verify/verify.php
@@ -17,9 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+define('ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/');
+
+require_once ROOT . '/php/session.php';
+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$code = $_POST['code'];
- $user_id = $_COOKIE['user_id'] ?? null;
+ $user_id = get_user_id();
if (!$user_id) {
echo "Not logged in.";