What is the purpose of using session_register() in PHP and what are the potential pitfalls of using it?

The purpose of using session_register() in PHP is to register global variables in the session. However, this function has been deprecated since PHP 5.3.0 and removed in PHP 5.4.0 due to security concerns. It is recommended to use $_SESSION superglobal array directly to set session variables.

// Deprecated way of using session_register()
session_register('variable_name');

// Recommended way using $_SESSION superglobal array
$_SESSION['variable_name'] = $value;