when you create the folder, it means everybody in the world will have access to it unless you protect it with a login of some description. Which may be okay for you, I don't know.
As soon as the folder is created, add a record to your DB table, such as
set the folder_name to the newly created folder name and the expiry to 30 days from now. So when your client tries to access any pages in the folder, you could have this in an include file to place in each page...
//connect to db
//get expiry date - if expired redirect to renew page - else show page
Alternatively, you could run a daily cron job to run a script to produce a .htaccess file into that folder which has the content:
So you want to create code for others to download onto their machines, which then expires after 30 days?
You could try hardcoding expiry into the php code and then use ioncube to encrypt the code. The problem with local php code is that it is visible, so the user could tinker with it. Likewise any DB tables.
You could use license keys, but this would probably mean a connection to the internet each time the user needed to use it.
You could maybe release a trial version with reduced functionality and then have a 'pro' version.
Sorry, this isn't really my area - all my stuff is strictly free code.
In addition, our forum guidelines ask that you show evidence of your own work. We've seen nothing so far. Although we are here to help, we're not here to write all your code, nor to do your research for you. You've been given a few pointers, but php is not particularly suited for this.
You could run a demo on your site and ask for payment which would lead to a download.