What are the potential pitfalls of using session_register() in PHP and why is it no longer recommended?

session_register() is no longer recommended in PHP because it is deprecated as of PHP 5.3.0 and removed in PHP 5.4.0. This function is insecure as it can register global variables without filtering or validation, potentially leading to security vulnerabilities such as register_globals exploitation. It is recommended to use the $_SESSION superglobal array directly to set session variables securely.

<?php
session_start();

$_SESSION['username'] = "example_username";
$_SESSION['email'] = "example_email@example.com";
?>