you would need to use file_exists() to check if the directory is created, if not crete is using mkdir.
you would need 2 statement the first to check the session directory, then to check the post directory name.
see this thread on webmaster world for details on how to do this:
r19705384-PHP-check-to-see-if-a-folder-exists