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?