diff --git a/src/Game.php b/src/Game.php index 2791436..c3cb91e 100644 --- a/src/Game.php +++ b/src/Game.php @@ -17,7 +17,9 @@ class Game */ public function __construct(bool $persistResults = false, int $maxResults = 5, string $timezone = 'America/New_York') { - session_start(); + if (session_status() !== PHP_SESSION_ACTIVE) { + session_start(); + } date_default_timezone_set($timezone); diff --git a/tests/index.php b/tests/index.php index c2426ce..558cbb0 100644 --- a/tests/index.php +++ b/tests/index.php @@ -6,4 +6,7 @@ $game->play('rock'); -var_dump($game->getResults()); \ No newline at end of file +var_dump($game->getResults()); + +# Make sure we can start a new instance without warning about session being already started +$game2 = new RPS\Game(true); \ No newline at end of file