一段时间后从服务器删除一些文本文件[关闭]

I am developing a online store. There is no sign up option. So i used Ajax and PHP to keep users wishlists and carts. For that i create some text file on the server.

Is that okay, or there is better way to do that?

Second question is; if I want to delete those text files after a certain period of time automatically, is it possible?

For storing information you might want to lookup MySQL or other type of database.

For dealing with information expiry date you can do two things:

  1. While storing new information to the database, add a added_on field with current datetime. Upon retrieval, check if that date is older than required period of time and use it accordingly.
  2. Another way is to also store the added_on date and use CRON jobs to check once in a while if that entry is older than required period of time and if it is, delete it.