How do you use stored variables across screens in thunkable x?

Let me explain to you the logic of your app.

When you start your app it will open screen 1, this will run
image
but nothing will show in the screen.
if you move to screen 2, this will run
image
You will see this is toto in the label in screen 2
When you move to screen 3, this will run
image
so only one label will show this is tata and the button will show false written on it.

When you type anything in the text field and press one of the buttons the text you typed will show in label3 or label6 depending which button you press
image

Now, watch carefully wat happens
if you move to screen 1 both stored variables will reset to the code in screen 1.
if you go back to screen 3 only one label will show the value because this is the code in the screen open block.

Stored variables are used to hold values that will not change a lot such as the user name so it is not expected to change with every screen. But your app is treating it as an app variable and it acts as it should.

Hope this is clear. Please feel free to ask for any specific detail.

1 Like

Oh ok. I’ll try experimenting with stored variables more.

1 Like

I created a sample app that makes use of Stored Variables
https://x.thunkable.com/projectPage/619b26462a8c5200388b8f38

Check it.
You will see that what ever you write in the stored variable stays even after exiting the app and open it again.

1 Like

Thanks a lot.

1 Like

So are stored variables useful for sign in?

1 Like

Stored variables are used for anything that you want to keep it even after the user exits the app so that your app remembers it next time the user open the app.

Stored variables are stored in the user phone so it makes sense to use it to save user settings for example or user ID.

In my sample app I’m storing a list of notes the user wants to keep it even after closing the app.

In some cases, you can use stored variables as local DB to save small size information.

If I want to use it for sign in, how do I exactly use the stored variables for the sign in?

1 Like

See this tutorial from Thunkable

1 Like

Thanks.

1 Like

I’m curious why you want to have users sign in.

  1. Are you planning to store data for each user?
  2. Do the users need to access their own data on multiple devices?
  3. Do you need access to the data stored for all users?
  4. Do you need to prevent some people from using the app?

Because it’s possible that you don’t need a sign in feature at all… that you just need to store the user’s data on the device. That doesn’t require a sign in.

2 Likes

I would like users to be able to log in in different apps every time I make them.

1 Like

And store data for each user

1 Like

When you use stored variable to store the data for app1 you will not see it when the user uses app2. Stored variable is saved in the user’s phone but it is private for the app that stores it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.