It would sound like you have a script with an ON EXIT or ON DISCONNECT event that might be clearing the variables.