move_detect/server/src/Auth/Session.php
유창욱 3f2823a764 refactor: rename cloud/ to server/ (cafe24 is web hosting, not cloud)
The PHP app runs on Cafe24 shared web hosting -- calling it 'cloud'
was misleading. Renames the directory, the edge client module, and
every doc/script/identifier that used the term.

- cloud/ -> server/ (incl. server/deploy/build_cafe24_package.sh paths)
- edge/cloudclient.py -> edge/serverclient.py, CloudClient -> ServerClient
- cloud/docs/cloud-deploy.md -> server/docs/server-deploy.md
- CLOUD_* env/config keys -> SERVER_*
- tests renamed to match

Tests: PHP 109 pass (4 skipped), pytest 167 pass. dist/ regenerated.
2026-07-20 11:30:52 +09:00

34 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Auth;
interface SessionStore {
public function get(string $key): mixed;
public function set(string $key, mixed $value): void;
public function clear(): void;
public function regenerate(): void;
}
final class ArraySessionStore implements SessionStore {
private array $d = [];
public function get(string $k): mixed { return $this->d[$k] ?? null; }
public function set(string $k, mixed $v): void { $this->d[$k] = $v; }
public function clear(): void { $this->d = []; }
public function regenerate(): void { $this->d = []; }
}
final class PhpSessionStore implements SessionStore {
/** @param string $cookiePath Scope the cookie to the mount ('/' at the web root,
* '/move_detect/' in a subdirectory) so a co-hosted site
* sharing the same www/ is never sent this session id. */
public function __construct(string $cookiePath = '/') {
if (session_status() !== PHP_SESSION_ACTIVE) session_start([
'cookie_httponly' => true, 'cookie_secure' => true, 'cookie_samesite' => 'Lax',
'cookie_path' => $cookiePath,
]);
}
public function get(string $k): mixed { return $_SESSION[$k] ?? null; }
public function set(string $k, mixed $v): void { $_SESSION[$k] = $v; }
public function clear(): void { $_SESSION = []; session_destroy(); }
public function regenerate(): void { session_regenerate_id(true); }
}