template.php: Throw exceptions on errors
session.php: Minor style fix
session.php: Refactor for tiny functions
session.php: Add a get/set session variable APi