Is it okay to leave a controller without a view? |
[eluser]rvillalon[/eluser]
I have a controller for error logging and is accessible by the browser. For example, I can access it and log an error by going to: http://www.mywebsite.com/error/save/acce...tl_details The last three parameters are used as follows: access_key : i match this in my config file to make thwart unwanted requests error_id : unique id to store addtl_details : additional error description Once it validates the information, I save into a database but I don't have any "VIEW" set up. It simply returns a blank page. Is this okay? Also, does anyone have any tips on how I might improve this?
[eluser]davidbehler[/eluser]
You call this controller using AJAX? Or what exactly do you do? If you call it using AJAX, then it's fine if it does only return a blank page, no ones gonna see it anyway. You don't have to use a view file, but as soon as you want to display content it's appropriate to do so, as a bunch of echo commands are pretty ugly xD
[eluser]rvillalon[/eluser]
Thanks, waldmeister! Also, what do you think of passing the access_key through flash? I included it to prevent unauthorized use of my error logger, but I think it can easily be sniffed for since it's coming from client-side. Any thoughts?
[eluser]rvillalon[/eluser]
Come to think about it, here's a better approach: Dynamically return file types through CI. This way, error logging can happen server-side. For example, http://www.mywebsite.com/request/xml/file_name would return an XML file Whereas, http://www.mywebsite.com/request/image/file_name returns an image file. I could do this by making use of Header. ie: Header('Content-type: image/png'); If there's an issue loading the file, I can log the error then. LOL Sorry for not thinking ahead! |
Welcome Guest, Not a member yet? Register Sign In |