What are some common methods for determining which player is active in a PHP game like 3-gewinnt?

In a PHP game like 3-gewinnt, one common method for determining which player is active is to store the player's turn in a session variable. This allows the game to keep track of whose turn it is and update the game state accordingly.

// Start or resume the session
session_start();

// Check if it's player 1's turn
if(isset($_SESSION['active_player']) && $_SESSION['active_player'] == 'player1') {
    // Player 1 is active
} else {
    // Player 2 is active
}

// Update the active player
$_SESSION['active_player'] = ($_SESSION['active_player'] == 'player1') ? 'player2' : 'player1';