design patterns - How should I lay-out my PHP login class? -


so, there going 1 login form; 1 of 3 types of members signing in member_type_a, member_type_b, member_type_c of whom have of same properties, , whom may have specific methods and/or properties them. want class saved session variable use member area pages.

any suggestions on applicable design patterns?

gordon: access control isn't issue... understand how control user allowed go. question on how structure login class; when user signs in, method search 3 tables valid username , password. when found, know type of user , able redirect them member page accordingly. i'm trying debate how can keep classes loosely coupled in such way, if had add more member types down line, endlessly scalable.

for example, 1 difference redirect url

i feel problem not login class user class. why don't use inheritance , create parent user class, create 3 sub-user classes. example:

class user {     $email;     $password;     $etc; }  class usertypea extends user {     $specific_property_1;     $specific_property_2;     $specific_property_3; }  class usertypeb extends user {     $specific_property_1;     $specific_property_2;     $specific_property_3; }  class usertypec extends user {     $specific_property_1;     $specific_property_2;     $specific_property_3; } 

keep common attributes , methods in parent user class, , unique attributes , methods in child classes.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -