web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Saving and Loading Dat...
Power Apps
Answered

Saving and Loading Data on start and exit

(0) ShareShare
ReportReport
Posted on by 60

Hey,

 

I've currently designed a log-in function and I'd like to make a "remember me" function for powerapps (Mobile app). The simple goal is to remember if the variable varLoggedIn is true or false upon application start. I'm guessing it works via SaveData and LoadData however I'm unable to figure out how this exactly works. Most tutorials online simply feature the basics of logging in without touching the subject of staying logged in even when the app is closed.

 

Thanks in advance,

// Thomas

Categories:
  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    There is no specific event that takes place if the app closes normally.  So the key to accomplishing what you want is to use LoadData in the OnStart and then SaveData whenever something in the app changes the value of the variable, for example if the user Logs out.  That way OnStart will always pick up the last known version of the variable.

  • ThomasDC Profile Picture
    60 on at

    Right, however I simply don't really get how the SaveData works. I've got the following:

    Set(varLogIn; !varLogIn);;
    
    SaveData(varLogIn; "MyCache")

     

    However this is incorrect. How would a simple variable be stored within the collection?

  • Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    You can store a variable as a value in a record in a collection.

    SaveData(varLogin; {value: varLogIn})

    But there really is no need for a separate login function since a user must be logged in to use the app in the first place.  Why are you implementing a Login functionality?

  • ThomasDC Profile Picture
    60 on at

    The application will be accessable for everyone in the team and only supervisors + will log-in for extra features.

     

    (Teams groep)

  • Verified answer
    Pstork1 Profile Picture
    69,661 Most Valuable Professional on at

    How many supervisors?  I would just create a list in SharePoint and have the app check the user().email against that list to determine if they are a supervisor.

  • ThomasDC Profile Picture
    60 on at

    A better and safer way to do this!

    I've changed the code, thanks a lot!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard