views:

110

answers:

2

On a portal's main page, I'm using a jQuery container plug-in, and by this users can hide a container by just clicking the minimize button on a container.

My question is: how can I save the user preferences in this regard? Then if the same user logs in again, I want to show the page based on user preferences. For example if a user hides the "sports news container" it won't be shown on users next visit.

+1  A: 

You just need to create a field in the users database table (or do something more complicated, if your database is complicated).

Then you can, if the field is set, place a script on the page that hides the container. And set a callback on hiding/opening which will send an Ajax request to your application, which will set the field to 1 or 0 (ON or OFF, whatever).

valya
+1  A: 

I think there are basically 3 options.

Cookies (so putting the preference value in $_SESSION) and hope the cookie is stored as long as possible.

Storing the preference at the database level, per user. @valya gave a solution like that. The obvious drawback here is that every user of the site, that you want to have preferences, needs a login.

Storing the preference in the database by IP address. This solution is pretty bad, but depending on your users this might work. So you store preferences per IP address. Users with a dynamic IP address or multiple users on the same IP address will have a bad experience.

Niels Bom
that's good too, thx a lot..
Serdar Boysal