Skip to content

Commit f348792

Browse files
authored
Update SessionHandler.php
1 parent c66cccb commit f348792

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/SessionHandler.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
class SessionHandler implements SessionHandlerInterface, SessionIdInterface, SessionUpdateTimestampHandlerInterface
1010
{
11+
public static $sessionSavePath = 'data/sessions';
12+
public static $sessionIdSize = 16;
13+
1114
private string $sessionSavePath;
1215
//private $sessionName;
1316
private string $sessionId;
@@ -28,9 +31,9 @@ class SessionHandler implements SessionHandlerInterface, SessionIdInterface, Ses
2831
* Coolision detection is absolute requirement for secure session.
2932
*/
3033

31-
public function __construct($save_path)
34+
public function __construct()
3235
{
33-
$save_path = realpath($save_path);
36+
$save_path = realpath(static::$sessionSavePath);
3437
//echo "Create [{$save_path}]\n";
3538
if (!file_exists($save_path)) {
3639
mkdir($save_path, 0755, true);
@@ -165,7 +168,7 @@ public function create_sid(): string
165168
// must generate secure session ID by yourself.
166169
// e.g. hash('sha2', random_bytes(64)) or use /dev/urandom
167170

168-
$id = bin2hex(random_bytes(16));
171+
$id = bin2hex(random_bytes(static::$sessionIdSize));
169172
//echo "CreateID [{$id}]\n";
170173

171174
// MUST return session ID string.

0 commit comments

Comments
 (0)