Welcome Guest, Not a member yet? Register   Sign In
Setting a session in the model or controller
#1

[eluser]randomdriver[/eluser]
Hello,

I have a programmer helping me build a project. I noticed he put the session setting in the model.

I.e. the model connects to the db, checks to see if there is a user match, if there is it sets the session:

$this->session->set_userdata($userArray);

Is there a best practice? Does this save overhead because you don't have to pass info to the controller?
#2

[eluser]danmontgomery[/eluser]
http://en.wikipedia.org/wiki/Model–view–controller


Quote:The model is the domain-specific representation of the data upon which the application operates.
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
The controller receives input and initiates a response by making calls on model objects.
#3

[eluser]randomdriver[/eluser]
So based on Wikipedia the session SHOULD be set in the model as best practice. However, I've seen several tutorials that set this in the Controller.

Anyone else have an opinion? I know I am splitting hairs here but am curious to know what the best practice is.




Theme © iAndrew 2016 - Forum software by © MyBB