My team and I have this Desktop client developed in JavaFX. It basically has a "Remember my password" checkbox. If the user ticks this checkbox, reboots, and reopens the app, the user should be automatically logged in. I'm using a cheap trick just saving a temp file to the temp directory. It's encrypted and it contains the information required for this feature. It just checks if certain info is present - if yes, login and go to dashboard.

Now what they want is if the user logs out (different from just closing the app) but ticked the checkbox beforehand, then the next time he opens the app the username and password will already be there. While I was thinking of a solution, my teammate suddenly pushes a fix to this problem. If the user ticks the checkbox, it saves the info (rewrites the file) to the temp file. If the user un-ticks the checkbox, the file is deleted.

Is this a safe practice?

Edit: Thanks Abigail for the comment. But disregarding that it's being saved to temp dir, let's say I'm saving it somewhere else, is the actual function of saving and deleting a file upon the toggle of a checkbox an "okay" practice?

  • Where do you store other user-related configuration parameters?
    – Doc Brown
    Commented Jan 15, 2019 at 7:24

3 Answers 3


These days it's common for an application to create and/or destroy multiple files per second. As long as you're sure you can't get into some sort of loop that creates/destroys files at high speed, and there's no chance that a partially-written file will give your app trouble (e.g. if someone yanks the power cord at an inopportune moment) then you should be fine.


The question cannot be answered without a specific use case. In your case I do not see an immediate technical problem with it but it is a very ad hoc hap-snap solution of which you do not want many more. User settings should be saved in a user settings file in an appropriate store (like the registry or a file in My Documents or elsewhere in C:\User... where it is safe and expected to reside). The system should read that and act accordingly. Now you have an implementation detail directly tied to a UI element which is inconvenient if you want to rework things and will likely go unnoticed when anyone looks at user settings later.


What you haven't specified is what happens if the user edits their details after ticking the checkbox.

As described, the stored details will not be updated, and the software will use the previously saved details next time they start the application. This could result in confused users if they have changed the password, but not un-ticked then re-ticked the checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.