You can determine the current state from the component's currentState property. In flex 3 default state is empty string. When you refresh the browser page (who does that when using a flash application?) you actually reload the entire flash application, meaning all your components will be recreated. So if you check your session, you then need to assign currentState of your component accordingly.
So based on your sample code, if you're viewing state 2, currentState of your component that defines the state, will now be "state2". This is the value you specified as the name of your second state. To set the viewing to first state, you can do
component.currentState = "state1";
as that is the name of your first state. To go to default (initial) state, you would do:
component.currentState = "";
To verify that you're on second state, you would do
if (component.currentState == "state2")
doSomething();
If your second state would be named "secondstate" instead of "state2", you'd be using:
if (component.currentState == "secondstate")
doSomething();
At least that's the way for flex 3, because as I understand flex 4 introduces some changes related to states.