php/sess.php
<?php
require_once('env.php');
$sst = session_start();
outBegin(__file__);
out('host', gethostname());
#out("session started $sst", $_SESSION ?? 'undefined');
out("session started $sst", $_SESSION ?? 'undefined');
$_SESSION['eins'] = 'ErstenS';
out('session_get_cookie_params', session_get_cookie_params());
if (is_array(@$_SESSION['authpw'])) {
# password_hash contains hashMethod and seed, thus it can be reused as seed
# crypt and password_hash are compatilbe
# password_hash(from valid PW, PASSWORD_DEFAULT))
$ph = '$2y$10$PyjclbiTH0uotBC.PVVJ5OdObAKsW40CcJh.8xVz8KcafYjVvvgKa'; # password_hash(from valid PW, PASSWORD_DEFAULT))
foreach($_SESSION['authpw'] as $k => $v)
out("$k => $v, decode " . base64_decode($k) . ", crypt=", crypt(base64_decode($k), $ph) === $ph ? 'matches': 'fails'
, ", password_verify=", password_verify(base64_decode($k), $ph) ? 'matches': 'fails');
}
$pw = 'tstPassW';
out("pw $pw, endode =", base64_encode($pw));
out("hash $pw h1=",$h1=password_hash($pw, PASSWORD_DEFAULT));
out("hash $pw h2=",$h2=password_hash($pw, PASSWORD_DEFAULT));
out('crypt pw h1=', crypt($pw, $h1), "crypt pw h2=", crypt($pw, $h2));
out('auth admin' , isset($_SESSION[crypt($pw, 'admin')]), ", cry1=",crypt($pw, 'nopass')
, ", hash2=",password_hash($pw, PASSWORD_DEFAULT));
outEnd(__file__);