how to get other script variable from other scene?

how to get other script variable from other scene?

Now, I have two java scripts from different scene(login.js, login scene and upload.js, upload scene )

I hope can get a variable from login scene in upload scene.

Used for android.

I’m Beginner, please give me a example code.
My English is very pool, hope we can know.

thank you!

Create singleton class,
store your variable into it,
access from other script in any scene.

login.js

class Login
 {
 
    // This is the singleton instance that is shared with everyone.
    private static var Instance : Login;
 
    // Everything that needs to get the singleton
    // instance, calls this function to get it.
    public static function GetInstance() : Login
    {
        if (Instance == null)
            // This is the first time the function was called.  Need to
            // construct the shared instance.
            Instance = new Login();
        return Instance;
    }
 
     var state : boolean ;
 
     // Private constructor.  This is what forces the class
     // to be a singleton since the only way to construct it
     // is via GetInstance().
     // NOTE:  Private constructors are not normally allowed
     // in JavaScript.  But it is OK in Unity.
     private function Login()
     {
        state=false;
     }
 
     function GetState() : boolean
     {
       return state;
     }
 
}

upload.js

private var control : Login;
 
function Start() 
{
    control = Login.GetInstance();
    Debug.Log(control.GetState());
    // The next line would cause a compile time error due to
    // the constructor's protection level.
    // control = new Login();
}

Hi!
The easiest way would be to create a static variable somewhere.
You might even create a static class to hold your persistent data.

you have to save that variable to playersPref then take it again in other scene