What are the potential issues with using GET parameters for language switching in PHP?

Using GET parameters for language switching in PHP can expose sensitive information in the URL, making it visible to users and potentially causing security risks. To solve this issue, it is recommended to use session variables to store the selected language instead of passing it through GET parameters.

<?php
session_start();

if(isset($_GET['lang'])) {
    $_SESSION['lang'] = $_GET['lang'];
}

// Default language
$language = isset($_SESSION['lang']) ? $_SESSION['lang'] : 'en';

// Use $language variable to display content in the selected language
echo "Current language: " . $language;
?>