View Full Version : Passwording a dir with MySQL Db?

02-12-2007, 11:29 PM
OK I have a few perl scripts in my cgi-bin. I want to move away from htaccess and try to password them using a MySQL Db where each client has their own data in the Db.

1. Is it possible to protect a directory in this way and,

2. Having 'logged in' to script 1 and they then want to go to script 2 how can I ensure that they do not need to log in again. SessionID's perhaps (gulp), but is it possible to pass a value, on login from a field in the Db record, exclusive to each 'logged in person', which would change every hour automatically or after they have been inactive (logged out) for more than 2 mins?

perhaps there is a way to store usernames and passwords in a MySQL Db which htaccess can use?

Any pointers appreciated


02-13-2007, 10:50 AM
Firs tof all sessions would be yourr best bet, you could use mysql but that would mean a call on every page to first check if they are within the time scale and second to set the time on the user, two un-needed sql commands when you can just use sessions which timeout anyway plus they carry on through all the pages.

as for the password a directory yes it is possible, I myself dont use .htaccess to password folders, instead on every file in that folder I call a function called checklogin() which checks the session variable, if there isn't one they get redirected to the login page.