You need to check if `isset($_SESSION['dir'])` to prevent "undefined index" notice.