How to secure a folder/document with session in codeigniter |
Most of the web applications stored confidential documents on different server/location and use these documents by a secured web API. But in case, if you are using the same server to stored the confidential documents, then you must need to secure the documents by session so that only authorized users can access these documents (like PDF, Images, ZIP, etc). Using this way you can also restrict unauthorized users to access any folder on your server.
You can achieve this in codeigniter or any other framework by using the following steps: 1) Create a htaccess file on root, if already created then skip this step. 2) Put this code in the .htaccess file: Code: RewriteEngine On a) Replace "document_folder_path" with your document folder path b) Replace "yourdomain.com" with your domain name c) controller_file: create a controller in controller folder with an index function 3) Put the below code to your controller file: Code: class controller_file extends CI_Controller
You can put this code in your.htaccess file
deny from all <Files ~ "^index\.php|JPG|png|jpg|JPEG|pdf"> Allow from all </Files> By:Xtreem Solution [Highly Skilled Laravel Developer](https://xtreemsolution.com/hire-laravel-developer.html) [Dedicated PHP Developer](https://xtreemsolution.com/hire-php-developer.html) |
Welcome Guest, Not a member yet? Register Sign In |