I have run into this a few times myself, I used a similar code to what you have posted but I found it better to password protect directories using .htaccess some think this is not the way to go but I find .htaccess is a quick and painless solution.
---
David Kittell
|