954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Best practice to check user session in MVC

Hey guys, what the best practice for session check without duplicate code. I mean when check the session in some controller I have to duplicate the code to other controller, and that is not a good idea.
<?php

class Ctrl extends Controller
{
   private function _ses_check() {...}
}
class Second_ctrl extends Controller
{
   private function _ses_check() {...}
}

Where I have to write this "main" things. Write in Model is again bad idea.
For that reason I write this topic. Thanks in advance!

gorleone
Newbie Poster
13 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Create a BaseController, include the session check, and derive your class from that one.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: