Flash authentication portal -- Weird Issue!

Hi,

I’ve made an authentication portal for my team using Flash.
After the user enters in his userid and password, he should be brought to the main menu.
What’s happening in the code is this:
On the second frame of the Flash movie, I’m checking for two session variables (userId and isUserValidated). If the two session variables are defined, then that means the user is already logged in. The movie skips to the “Main Menu” frame, which displays a customized menu for the user.
However, if those two session variables are NOT defined, then that means the user is not logged in, and the movie keeps playing until it hits the UserId and Password prompts.
From there, the user logs in, his userid and password are passed to a Logon_Validator.cfm module, which basically determines whether his userid/password combination are correct or not. If the logon is successful, then the Session variables are set, and the webpage containing the Flash movie is re-loaded (in order to get the session variables). Once the re-loaded Flash movie gets to the second frame, it sees that the two Session variables are defined, so it skips to the “Main Menu” frame.
However, what happens sometimes (maybe 10-15% of the time) is that, after the user logs on and gets his session variables set, the re-loaded Flash movie seems to pass right over the code in the second frame that checks for the two session variables.
This is what the Flash ActionScript code on the second frame looks like:

 
stop();
 
if ((sBACUserID != "") && (sUserValidated == "YES")) {
 _global.username = sBACUserID;
 gotoAndPlay("main menu");
} else {
 play();  // plays until the Userid-password prompt
}

I’m confused as to why sometimes this “if” block is skipped over. Am I handling session variables in Flash the correct way? (re-loading the webpage to get the variables into the movie) Any help would be appreciated! Thanks.