I've been trying to figure out what is considered best practice(s) when it comes to storing, retrieving and cleaning up search results in a PHP/MySQL combination. I haven't found too many in-depth discussions about this on the internet, so I've come up with my own solution, and I hope some of you more experienced coders could offer some input.

First of all, I want people to be able to open a new tab in the same browser to conduct a new search while keeping older search results in the first tab (in order to compare the results or whatever). So session id can't be used to keep track of search results. Instead each search need a unique id, and I've chosen time. At the end of each search the variable $t is assigned current time, i.e. $t = time(). The search results are then saved in a plain textfile named with a combination of session id and $t to ensure its uniqueness. The total number of hits and some other search-related data are stored in session variables such as $_SESSION[$t]['no_of_hits'], $_SESSION[$t]['query'].

On each page of results I show, say, 10 hits and 10 links to other pages. The URLs for the links to the other pages contain page number and the time of the search (i.e. "...?t=1378893448&p=2...") which are used to identify the right file and retrieve the right contents of it (after checking if there is such a file).

As for cleaning up, I let the users help doing that. After each search a check is made to see if there are any search-result files older than 1 hour. And if there are, they are deleted.

Does anyone see any problems with this, or have any suggestions for improvements or alternative (better) solutions?
Thanks.