how to make a download directory for valid users without being logged in, just by browser authentication?

StackOverflow https://stackoverflow.com/questions/18481415

Question

Hi and best greetings to everybody!

as the subject shows i am trying to make a directory in my server which only valid users are allowed to download from. of course i don't want my users to be logged in to my site but only got authenticated by asking their usernames and passwords before downloading files through their browsers.

i know how to do it with ".htaccess" and ".htpasswd" files. but the problem is here that as the number of users grow, the size of ".htpasswd" grows too! and this is a big problem! although i cant set start and expire date for my users in this way.

i wanna know if there is any code doing my job with php and mysql (or probably using jquery)

moreover, is it possible to config ".htaccess" file in a way that it use php and mysql authentication (using users database)?

i say again that i need to set start and expire date for my users that a crone job will check it so if the expiration time has arrived does not let user downloading from the directory with printing expiration note.

of course the other way is that the crone job delete user from database when his/her time has expired.

any ideas?

thanks everybody in advance.

Was it helpful?

Solution

Heres is an official solution:

http://php.net/manual/en/features.http-auth.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top