I have a query, if i have an application structured in an MVC like way, with a controller and views - but simply using PHP without any framework.
I want a section to be restricted for logged in users. So say i have a controller class that manages login
class Access
{
login function
{
loads login page
}
process login function
{
processes login details submitted by POST, sets the session and redirects to the login homepage
}
logout function
{
destroys the session and loads the logout page
}
}
Where would be the best place to place the SET SESSION and SESSION destroy?
Is it in the controller class or in the views that are loaded?
Or do i have to pass it to the View from the controller as a variable?
Also, if i have multiple controllers and views that are suppossed to be accessed only when logged in, do i create an include file to hold the session settings and where is the best place to place it? In the controller's constructor or in each view <head> part of the file?