I want to protect a URL in my site For exapmle: http://www.mysite.com/admin using user “Login”
I don’t want to let anyone see any content in the “admin” directory not even a picture or any other file. How could this be possible? i have read about the sessions and all but that can stop a user to access a webpage. I am familiar with PHP. Please help!
I want to protect a URL in my site For exapmle: www.mysite.com/admin using user
Share
It’s a little bit ugly, but the easiest way would be to password protect the directory, which would bring up an authentication pop-up type box to the browser. If you are using Apache, you can find out more information in the Apache docs. If you are using another server, they will likely have similar docs available somewhere. This can also be done directly by PHP by sending the correct header in order to authenticate against a database instead of storing the users’ information in a text file.
If you are looking to make it seamlessly integrate into your site (i.e. without the ugly pop-up), it is a bit more difficult, but doable. The PHP files are easy. Just write some sort of code to determine if the user is logged in, and if not, don’t show the content. However for the images or other static files, I would recommend doing something like this: Echo/print a jpg-image with php, for safety?