<?php
// checking to see if domain has a port number attached (localhost)
$domain = $_SERVER["HTTP_HOST"];
if (strpos($domain, ":")) {
// strip the port number if present
$domain = explode(":", $domain)[0];
}
// used for public hosting like heroku/render.com
if ($domain != "localhost") {
session_set_cookie_params([
"lifetime" => 60 * 60, // this is cookie lifetime, not session lifetime
"path" => "/project", // path to restrict cookie to; match your project folder (case sensitive)
"domain" => $domain, // domain to restrict cookie to
"secure" => true, // https only
"httponly" => true, // javascript can't access
"samesite" => "lax" // helps prevent CSRF, but allows normal navigation
]);
}
session_start();
require(__DIR__."/../lib/functions.php");