How to pass variables from one object in one scene to another object in another scene?

Is it possible to pass variables from one object in one scene to another object in another scene?
If so, I need to pass unityNameSelected global variable from first script(which is listed bellow) attached in an object in scene 2 to the second script attached to another object in the scene 1. Thanks for any help.

{
			
        while ( reader.Read() ) 
        {
            if ( reader.NodeType == XmlNodeType.Element ) 
            {
                if ( reader.HasAttributes ) 
                {
                    if ( reader.GetAttribute("UnityName") != null ) 
                    {
                        unityName = reader.GetAttribute("UnityName");
                        if(!values.Contains(unityName))
                        {
							values.Add(unityName);
							DontDestroyOnLoad(GameObject.Find("unityName"));	
       
    		
									 unityNameSelected = unityName;
								//string[]	unityNameSelected3 = {unityName};
								//		unityNameSelected =unityNameSelected3;
										print(unityNameSelected.ToString());
										 
				}
							}
                            }
                    }
                }}

alucardj is right:
The right solution (which I use as well because the variables get saved even after you close the app) is PlayerPrefs

My login page code:

function Awake(){
      if(!Username && PlayerPrefs.HasKey("Username") && PlayerPrefs.GetInt("Remember")==1){
		getUserPrefs();
	}
}
function getUserPrefs(){
	Username=PlayerPrefs.GetString("Username");
	Password=PlayerPrefs.GetString("Password");
}

function saveUserPrefs(){
	PlayerPrefs.SetString("Username",Username);
	PlayerPrefs.SetString("Password",Password);
	PlayerPrefs.SetString("User",Username);
	if(createCookie){
			PlayerPrefs.SetInt("Remember",1);
		}else{
			PlayerPrefs.SetInt("Remember",0);
		}
	PlayerPrefs.Save();
}

very easy to use for single value :), actually I’m going to pass array values which collects at least 5 string values. Is there a way to pass them through PlayerPrefs?

You can store anything in player prefs if you use the BinaryFormatter.

var m = new MemoryStream();
  var b = new BinaryFormatter();
  b.Serialize(m, anyObjectYouLike);
  PlayerPrefs.SetString("ClassData", Convert.ToBase64String(b.GetBuffer()));

Like this to decompress it:

  var m = new MemoryStream(Convert.FromBase64String(PlayerPrefs.GetString("ClassData"));
  var b = new BinaryFormatter();
  var o = (AnyObjectYouLike)b.Deserialize(m);

You’ll need System, System.IO and System.Runtime.Serialization.Binary I think. The class has to have a parameterless constructor.