// now lets go through the tree and delete the folders
walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
+sqimap_logout($imap_stream);
+
+// close session properly before redirecting
+session_write_close();
$location = get_location();
header ("Location: $location/left_main.php");
-sqimap_logout($imap_stream);
-?>
\ No newline at end of file
+?>