I am using Codeigniter to build my project.
Here i have some doubts or need some clarification.
Can i use Constructors to do somethings that which affect all other functions in codeigniter/php ??
Please take a look here :
<?php
class New extends CI_Controller
{
function __construct()
{
//Constructor codes...
}
function Create_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function Edit_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function Delete_page() //The user need to be Logged in to perform this
{
//Checking whether the user logged in or not if yes allowed else denied.
}
function about_us() //This is a public action no need to Log in
{
// this is a pulic action ,no need to check the login status
}
}
?>
As you can see that i need to check the Logged in status on each Private functions ,
Is there any way that i can do this on constructor ? so that constructor will check logged in or not ....but it will only need to affect some Functions...