# How to store persistent data between sessions?

**URL:** <https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075>\
**Category:** How-to Discussions\
**Created:** [April 30, 2015, 6:14pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075 "2015-04-30T18:14:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eivind](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eivind/32/575_2.png) [@Eivind](https://forums.fusetools.com/u/Eivind)\
**Post date:** [April 30, 2015, 6:14pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/1 "2015-04-30T18:14:50Z")

</div>

I’d like to store some data between sessions of my application running. (Specifically: the user’s log-in details!)

What’s the best practice for this?

I’ve found Uno.IO.File, which I suppose would do the trick, but what path/filename should I use so that it will work on all platforms?

---

<div class="post-metadata">

**Author:** ![Havard\_Homb](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/havard_homb/32/229_2.png) [@Havard\_Homb](https://forums.fusetools.com/u/Havard_Homb)\
**Post date:** [April 30, 2015, 6:54pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/2 "2015-04-30T18:54:41Z")

</div>

I’m using:

```auto
File.WriteAllText(Directory.GetUserDirectory(UserDirectory.Data + "/Filename.txt")
File.ReadAllText(Directory.GetUserDirectory(UserDirectory.Data + "/Filename.txt")

```

to store data. Works on every platform except webgl as far as I know

---

<div class="post-metadata">

**Author:** ![Eivind](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eivind/32/575_2.png) [@Eivind](https://forums.fusetools.com/u/Eivind)\
**Post date:** [May 1, 2015, 12:51pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/3 "2015-05-01T12:51:28Z")

</div>

Thanks! do you think it’s safe? Should I store access tokens etc like this?

---

<div class="post-metadata">

**Author:** ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)\
**Post date:** [May 1, 2015, 2:04pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/4 "2015-05-01T14:04:48Z")

</div>

Håvard’s approach is OK for most use cases.

If you have particular security concerns, look up the prefered way of doing it using the iOS and Android APIs respectively.

Note that you can add references to the `Android` and `Experimental.iOS` packages to access any of the native APIs directly from Uno code.

---

<div class="post-metadata">

**Author:** ![Havard\_Homb](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/havard_homb/32/229_2.png) [@Havard\_Homb](https://forums.fusetools.com/u/Havard_Homb)\
**Post date:** [May 2, 2015, 6:10pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/5 "2015-05-02T18:10:47Z")

</div>

Yeah forgot to say. The data I store is very non sensitive, so security wasnt a concern 🙂

---

<div class="post-metadata">

**Author:** ![Cristian\_Karmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy/32/480_2.png) [@Cristian\_Karmy](https://forums.fusetools.com/u/Cristian_Karmy)\
**Post date:** [June 16, 2015, 3:33pm UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/6 "2015-06-16T15:33:12Z")

</div>

hello, i need to do the same, store the user id, name, username, profile pic path, and session token (from parse) for that user and some device data like the id of the instalation and stuff like that, is it safe to do it this way?

(that file is per instalation, so it’s data is unique to each phone)

also, i need to check if that file exist when you open the app and if it does, get the data of the file and store it on variables in the app.

Thanks.

---

<div class="post-metadata">

**Author:** ![Eivind](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eivind/32/575_2.png) [@Eivind](https://forums.fusetools.com/u/Eivind)\
**Post date:** [June 21, 2015, 9:51am UTC](https://forums.fusetools.com/t/how-to-store-persistent-data-between-sessions/4075/7 "2015-06-21T09:51:24Z")

</div>

yup, exactly the same use-case 🙂
