I'm putting together a site, entirely my own project, where you can process images in all kinds of ways, crop and resize them, add text in any variety of fonts, colors and sizes, add insets of several kinds, make flyers and posters, etc,etc, etc. All of that works and wasn't that hard to write.
But here's my problem, I've set it up so that as soon as someone enters the site they are assigned a name for their working folder and as soon as they upload a picture the folder is made, inside a folder named Pool, then the images are placed inside their folder. But I don't want to store images, I want the folder and its contents to be automatically deleted shortly after their browser is closed and their session ends. How do I do this, I don't know, haven't got a clue, about how to call a function at the end of their session or after it has closed. Because nothing is stored and the site is intended to be free ( except maybe for advanced users ) I see no need for a database.
PHP does not natively support what you want to do.
The only way to do that, is have your users click a link like logout / finish or to run an automated process.
For the latter option you could in your pages use an ajax request to poll a script every 5 seconds. That script then records the time/date access somewhere - either in the session (not a wise idea), file or DB. On the webserver, have a cron job that runs every 5 minutes and wipes out all files that haven't been used for 5 minutes or more.
The reason I say using sessions to record the time is not a good idea is quite a simple one. Your cron script would need to be able to access all the session files for visitors to your site. While thats not particularly difficult on a windows platform, on a shared host under linux it may be very difficult.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
I know there is an beforeunload (I think thats the right one), but its not a safe thing to use as javascript can be disabled, and you'd just be in a mess.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
I now know that php doesn't natively have such a function. I plan on having more than one way of doing it, such as a weekly cleanup of all files and folders in Pool. I already have it set so they can delete their own files. People have to use javascript on the site, so I can set it so that if they don't have javascript enabled they can't make a folder or upload. I could maybe put a 'cookie' in their folder with just the unix time when they quit on the cookie, and that can be checked regularly. Anyway, I have some ideas now.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
SQlite was bundled with PHP from 5.0 but they are dropping it back into PECL from 5.4 for reasons I do not know (mad cos with a built in webserver 5.4 would be complete script/server/db all rolled into one... anyways)
I think what Arcticwarrio meant is that with SQLite you could but the database file anywhere you wanted ona per-database/usage basis as opposed to MySQL where you can't change the database path unless you are root.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)