![]() |
Direct access to views - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Direct access to views (/showthread.php?tid=6907) |
Direct access to views - El Forum - 03-17-2008 [eluser]luukskywalker[/eluser] I have a small question regarding views. I am working on a login system for a new web application. When users log in and validated their username and password, the variable logged_in in the session changes to true. My question is: Is it possible to access views via url's? If not, then i can just check the loggin boolean at the beginning of the functions after users logged in. Direct access to views - El Forum - 03-17-2008 [eluser]Glen Swinfield[/eluser] You cannot map an URL to a view, just make a controller method that includes your view and nothing else. class Test extends Controller { function my_view(){ $this->load->view('my_view'); } } Direct access to views - El Forum - 03-17-2008 [eluser]luukskywalker[/eluser] Allright Thanks I was afraid people could get to my view by putting http://www.website.com/codeigniter/my_view.php in the address bar! but its solved than ![]() Direct access to views - El Forum - 03-17-2008 [eluser]xwero[/eluser] This is possible if you allow the view file as a stand alone file which is the case on most servers but you could set server restrictions in the .htaccess or the webserver configuration or you can add following line to the beginning of each view file Code: if (!defined('BASEPATH')) exit('No direct script access allowed'); Direct access to views - El Forum - 03-17-2008 [eluser]MadZad[/eluser] Additionally, it's generally wise to keep all files out of the webroot unless necessary. CI makes this very easy, and the only things I have left in the webroot are css/js/image files, an index.php and .htaccess for each application, and ci_config.php and .htaccess in my CI directory (above the application dirs). |