-
Notifications
You must be signed in to change notification settings - Fork 1
/
loader.php
39 lines (30 loc) · 946 Bytes
/
loader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$hashed_db_password = hash('sha512', $db_password);
// Init database
$postgresql_db = pg_connect("host=$hostname port=$port dbname=$dbname user=$dbuser password=$dbpassword");
// Secure Session
header('X-Frame-Options: SAMEORIGIN');
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$secure = true;
} else {
$secure = false;
}
$httponly = true;
$samesite = 'strict';
$maxlifetime = 60 * 60 * 24;
if(php_sapi_name()!="cli") {
if(PHP_VERSION_ID < 70300) {
session_set_cookie_params($maxlifetime, '/; samesite='.$samesite, $_SERVER['HTTP_HOST'], $secure, $httponly);
} else {
session_set_cookie_params([
'lifetime' => $maxlifetime,
'path' => '/',
'domain' => $_SERVER['HTTP_HOST'],
'secure' => $secure,
'httponly' => $httponly,
'samesite' => $samesite
]);
}
}
session_start();
?>