How do you create Log out?

Hello. I'm creating an app where users need to log in, and upon logging in, it should display the user's name and other details on the next screen. However, I'm encountering an issue with implementing the log out button. I want users to be able to log in with different accounts and see their full details on the next screen. The problem is, the data from the previous session remains when a new user logs in. I'm seeking advice on how to implement a log in button that clears all previous data from the screens so that when a user logs in, only their data is displayed.

I'm using Firebase and TinyDB

For a label:
image

For tinyDB, if you want to remove the data associated to a user:
image

Or if you want to remove all the data:
image

When I use 'clear all,' does it only delete the displayed data(Not affecting the saved data), or does it remove all saved data as well?

Since I wasn't is when I log out then log in another user it would display the save data like picture, list, name, etch. Then when log out it would just clear the data on screen but not delete it in database.

I also want to know if this would affect all the screen if I have 3 or more screen.

Yes, clearAll will remove all the info from tinyDB and "ClearTag" all the info associated to that tag.

If you want to keep the users info in tinyDB then don't use those blocks.

So I can only use the first one?

Also just want to know how can I also clear the display data to other screen when I hit the log out button?

What do you mean with this?

Regarding to "clear" a screen, it depends on what do you have in the screen and what do you understand by "clean"... set the labels, textboxes to an empty string, set the variables to the initialization value...in short, leave the screen as when it was started.

I mean the 'set label to blank,' referring to the first block you provided.

What happens when the user goes back to that screen? For example, there are three buttons: home, shop, and profile. When the user clicks on 'profile,' it displays the name, picture, etc. Then, when they click on the other buttons, it sets the details to blank again. How about when the user clicks the 'profile' button again? Will it display the user's name and picture, or will it remain blank?

I'm confused...weren't we talking about a log out button?

If the user is still logged in and is browsing between screens, they will not be logged out. So, if you don't want the information to disappear from the label, don't remove it...

How is a user session supposed to be like in your application from the time they log in to the time they log out?

If while logged in you want to clean a label and then want to recover that value again, no problem, that's why it has the information stored in tinyDB.

Yes the log out button just wondering if when I click log out button it would clear all display data to other screen as well Hehehe. Sorry if it's confusing. Just want to ensure. But thank you