I am very curious as to why all the main PHP frameworks like zend use setter and getter methods to set and get basic $_SESSION[‘user’] variables? I am doing it myself right now but I really don’t know why I am, other then the fact that I see it being done fairly often by others now. So in theory at least, it seems like wrapping these into a class would just add more overhead and I just want to know if there is any reasoning behind this trend?
Share
One reason is that most of them allow you to store the session in a different way like a database. So you can always use get/set no matter how your session is handled.
EDIT: CodeIgniter for example checks if the session is valid after it got called (IP, Browser). So you don’t have to call a “check function” right after you called session_start().