开发者

Should I set sessions for all my site settings or access them via class variables?

Whats a good way to set this up.

I want to allow users to add themes to their profile and each time they log in for that theme to be applied. (the themes are saved in the database)

I have thought of 2 ways to do this.

1) when they log in for a session to be made holding theme information, like theme name, theme source, etc.

2) when they log in to call in get_theme() function in开发者_运维技巧 my __construct() that will query the database for the data and apply it to public variables in my class that i can call from within my application?


This is Barbareek. I possess more than 4 years of experience on Java/J2EE stack of technologies.

If I understood the question correctly, you basically trying to save the user's profile theme information. This question should better be addressed like:

  1. There must be a table in the database representing the persistent entity, in this case the user.
  2. All the themes are defined statically i.e. you provide the user the options for the themes that have already been define in the data store.
  3. The theme attribute must be a part of the user entity, that needs to be set, for an individual user as he/she wishes. Save this information as you are saving the other details for the member.

Hope this helps.


Second one is not an option at all. You cannot use a PHP class to store anything between calls, as it just will die in less than second like all php scripts do.
So, the only choice is persistent storage, like database or session.


Since you have the theme information already in the database and I suppose you may have designed a table for a theme that have certain attributes, the primary key or the discriminator column being the name of that theme.

As the user performs the activity in the session, he/she can choose among the name of available themes and based on name you just pull that information from back end database when the USER session creation is in process.

thanks...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜