Sorry, I'm not quite sure what you're asking. Are you creating new directories for each user/password combination and trying to auto-generate an .htaccess file for each? Timeout on each directory, too?
.htaccess files are heirarchical, i.e., the DocumentRoot's .htaccess directives will apply to all subdirectories unless further directives are within those directories' .htaccess files. This does not sound like it would help with what you've (almost) described.
When creating a new username/password, you seem to need a new directory with its own .htaccess file. If your new directory is created automatically, that same script can also create an .htaccess file for that directory. The only thing missing at that point would be the 'nix password file for that directory (see how ugly this is getting?).
IMHO, this is getting overly and unnecessarily complex.
Thinking outside the box you almost described, I would build an access page to query your database (for username, password and expiration date) and provide the data from OUTSIDE your webspace (meaning from a directory at the same level as your public_html directory) via PHP.