Keep logged in when scene changed(Playfab)

I have created a login system using Playfab. But the problem is when I change my scene it automatically logs out. Now, is there any solution to this? I mean can I keep logged in every scene?

 public Text messageText;
 public Text messageReg;
 public Text messagelog;
 private string userEmail;
 private string userPassword;
 private string username;
 public GameObject loginPanel;
 public InputField emailInput;

 public static PlayfabManager PFM;


    public void OnEnable()
    {
        if (PlayfabManager.PFM == null)
        {
            PlayfabManager.PFM = this;
        }
        else
        {
            if (PlayfabManager.PFM != this)
            {
                Destroy(this.gameObject);
            }
        }
        DontDestroyOnLoad(this.gameObject);
    }

    



    void Start()
    {
       
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = " CFB1C";
        }
        //PlayerPrefs.DeleteAll();

        if (PlayerPrefs.HasKey("EMAIL"))
        {
            userEmail = PlayerPrefs.GetString("EMAIL");
            userPassword = PlayerPrefs.GetString("PASSWORD");
            var request = new LoginWithEmailAddressRequest
            {
                Email = userEmail,
                Password = userPassword
            };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
        }
        

    }

    #region Login
    private void OnLoginSuccess(LoginResult result)
    {
        Debug.Log("Logged In!");
        PlayerPrefs.SetString("EMAIL", userEmail);
        PlayerPrefs.SetString("PASSWORD", userPassword);        
        messagelog.text = "Logged In!";
    }
   
    private void OnRegisterSuccess(RegisterPlayFabUserResult result)
    {
        Debug.Log("Register and logged In!");
        PlayerPrefs.SetString("EMAIL", userEmail);
        PlayerPrefs.SetString("PASSWORD", userPassword);
        messageReg.text = "Register and logged In!";
    }

    private void OnLoginFailure(PlayFabError error)
    {
        var registerRequest = new RegisterPlayFabUserRequest
        {
            Email = userEmail,
            Password = userPassword,
            Username = username,
        };
        PlayFabClientAPI.RegisterPlayFabUser(registerRequest, OnRegisterSuccess, OnRegisterFailure);
    }

    private void OnRegisterFailure(PlayFabError error)
    {
        Debug.LogError(error.GenerateErrorReport());
    }

    public void GetUserEmail(string emailIn)
    {
        userEmail = emailIn;
    }

    public void GetUserPassword(string passwordIn)
    {
        userPassword = passwordIn;
    }

    public void GetUsername(string usernameIn)
    {
        username = usernameIn;
    }

    public void OnClickLogin()
    {
         var request = new LoginWithEmailAddressRequest
         {
             Email = userEmail,
             Password = userPassword           
    };
    PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
    }

Hi @ahnafshakib41 the reason is because the object (on which the login information is stored) is destroyed when the new scene is loaded. This object will need to be a singleton, which means it will persist between scenes. The simplest way is to include the DontDestroyOnLoad in the script. The better way is to have the class (which holds the login information) be inherited from a singleton class. Here’s what I use:<pre>public class Singleton<T> : MonoBehaviour where T : MonoBehaviour { private static bool _Shutdown = false; private static object _Lock = new object(); private static T _Instance; public static T Instance { get { if(Singleton<T>._Shutdown) { Debug.LogWarning("Singleton<"+typeof(T)+">: Instance: Shutdown enabled. Returning null."); return null; } lock(Singleton<T>._Lock) { if(Singleton<T>._Instance==null) { Singleton<T>._Instance=(T)FindObjectOfType(typeof(T)); if(Singleton<T>._Instance==null) { GameObject tempSingleton = new GameObject(); Singleton<T>._Instance=tempSingleton.AddComponent<T>(); tempSingleton.name=typeof(T).ToString()+" (Singleton)"; GameObject.DontDestroyOnLoad(tempSingleton); } } return Singleton<T>._Instance; } } } private void OnApplicationQuit() { Singleton<T>._Shutdown=true; } private void OnDestroy() { Singleton<T>._Shutdown=true; } }

And to inherit from it, use the same name of the child class as the generic:<code><pre> public class GameManager : Singleton<GameManager> { }</pre>

Then when you access the parameters of that object, you use the Instance getter:<code><pre>Debug.Log("Email is: " + GameManager.Instance.loginEmail);</pre>