When I run the following code on my local machine (macOS using MAMP Pro), it works fine. Yet when I deploy the same to a live server running centOS, it doesn't want to store the session cookie in my browser.
$cookieParams = session_get_cookie_params();
$lifetime = (!empty($session_lifetime = env('SESSION_LIFETIME'))) ? $session_lifetime * 60 : 3600;
session_set_cookie_params([
'lifetime' => $lifetime,
'path' => $cookieParams['path'],
'domain' => env('APP_URL'),
'secure' => true,
'httponly' => true,
'samesite' => 'lax' // lax
]);
session_name('WEBSESSION-UUID');
session_save_path(Path::storage_path('framework/sessions'));
ini_set('session.gc_probability', 1);
ini_set('session.gc_maxlifetime', $lifetime);
if (empty($_SESSION['SESSION_ID'])) {
if (self::isSessionStarted() === false) session_start();
$_SESSION['SESSION_ID'] = hash('crc32b', uniqid() . date('Y-m-d H:i:s') . uniqid());
}
session_regenerate_id(true);
Sessions are created in the correct location, which is stated in the session_save_path. Yet every time I reload the page, it'll load a new one. The domain is also the exact domain I am using to call the page.
Permissions of the session_save_path folder are set to 755 with apache:apache as the owner.
Sessions are again, successfully created. If I print the session_id after session_start, it'll output a session. It really appears to be somewhere in the cookie, which has to link the php session to the user session.
Am I not noticing something really obvious?
Edit: No errors what so ever. The only error I got was a permission error, which I fixed by chown -R apache:apache folder/
.