I am creating a service that allows my website visitors to create content (text) and save it so they can access it at a later time. However, users don’t need a user account before they can use this feature. They just click “Try now” and use it. If they want to save their work, then that’s the time they need to sign up.
I am planning to add Uploading of images/files as a feature. However, I’m at a loss for ideas on how to implement this for the “Try now” mode (non-logged in user). On top of my head, I would create a temporary username and store it in a session, and create a corresponding temporary folder where the user’s uploads go to. But, how do I clean it up? The user can just close the browser, and I will have no way of knowing the temporary folders are still being used.
Is there a better way of doing this? Or should I just prevent uploading of files for non-registered users altogether?
I’m using PHP on CodeIgniter by the way.
Your input would be invaluable 🙂 Thanks!
Here one of possible ways to do:
Then, you can regularly check for obsolete files. For example, if your session limit is 30 minutes, you can walk through the database and select every expired session, ie. the records where the datetime + 30 minutes is less than now. Then, remove every file stored through those expired sessions.