View Full Version : save data locally to some ini file, for later use

11-01-2012, 10:21 PM
can save its data locally to a config file?

I would like the app to retain some parameters later sessions.

11-01-2012, 10:29 PM
INI file, no.. not in JavaScript. COOKIE, yes. document.cookie can keep some parameters for later sessions.

Philip M
11-01-2012, 10:29 PM
JavaScript running in a browser is a client-side language. JavaScript does not have any commands for reading or writing files.

You can save data using a cookie or local storage.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

11-01-2012, 11:00 PM
The downside being that if cookies are disabled, it won't work.. but you can run a check, for that, and if cookies are disabled then display a message "Hey, enabling cookies helps me help you enjoy the site more."

11-01-2012, 11:09 PM
okay, that might do. but what if it gets turned into an air app?

11-01-2012, 11:15 PM
As much as I have wanted to learn AIR, I couldn't tell you if cookies will work.

11-01-2012, 11:28 PM
It might be tricky, but maybe someone has managed with it so far?

Old Pedant
11-02-2012, 03:32 AM
Look here:

Yes, you can save to local files using AIR.

Completely different rules with AIR than with a browser.

Here's some example code that is supposed to work *IF* you set the permissions correctly in the XML manifest file.

var file2:File = File.applicationStorageDirectory.nnativePath("myFav.txt");
fileStream1.open(file2, FileMode.WRITE);

I haven't tried it. But the code makes sense.

Note that NONE of this will work in a browser!