Welcome Guest, Not a member yet? Register   Sign In
Redirect vs load view
#1
Question 
(This post was last modified: 09-16-2018, 10:27 AM by Serializable.)

When should I use redirect and when
Code:
$this->load->view('projects/page');
?
For example, in the following code snippet what will be more preferable to use?


PHP Code:
class Projects extends CI_Controller
{
   public function __construct(Type $foo null)
   {
       parent::__construct();
       if (!$this->session->userdata('logged_in')) {
           $this->session->set_flashdata('flash_danger''Please login to view this page');
           redirect('home'); // maybe to use `$this->load->view` here?
       }
   }

   public function index()
   {
      ... 


And another question  - am I uderstand it right, that controller object (the object of class  Project) will being created every time I request to this controller?
So will the function  `__construct` be process every time before controller logic will be processed?
Reply


Messages In This Thread
Redirect vs load view - by Serializable - 09-16-2018, 10:22 AM
RE: Redirect vs load view - by InsiteFX - 09-17-2018, 03:45 AM
RE: Redirect vs load view - by Serializable - 09-17-2018, 06:59 AM
RE: Redirect vs load view - by Pertti - 09-17-2018, 08:00 AM
RE: Redirect vs load view - by Wouter60 - 09-17-2018, 08:37 AM
RE: Redirect vs load view - by dave friend - 09-17-2018, 09:16 AM
RE: Redirect vs load view - by Serializable - 09-17-2018, 12:25 PM
RE: Redirect vs load view - by dave friend - 09-17-2018, 04:43 PM
RE: Redirect vs load view - by ignitedcms - 09-21-2018, 11:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB