function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Koen (BvD)Koen (BvD) 

Settings per user

Is there somewhere I can store a setting per user, or a setting maintained during the session that I can access from Visual force? Creating a custom object with a reference to the user seems a "heavy" solution if its just to remember the last option chosen.

ThomasTTThomasTT

The concept "Session" is confusing with SFDC. There is session & sessionID in SFDC, but we can hardly access to the scope, it's SFDC internal. All we can store data in is View State in your browser and SFDC database.

 

You can store values accross page transitions in the controller only when

 

- The both page from and to are using the same controller / extension

- Returned PageReference object from action method is not set redirect true (default is false).

 

For example, if you return null from your action method, it stays in the same page, which meets both of conditions and all values are kept. When you see Wizard type VF pages, they are using the same controller among the pages. To keep the value, you don't need to do anything. All values will be automatically kept unless you specify "transient"modifier.

This means, this is not exactly same as "Session" scope. If you want to share values among pages with different controller, it can't work. You'll need to pass values you want to keep via database or URL parameters.

 

Setting per user... if you mean a setting which is always same everytime a user login to the system, that would need to be stored in a cusom field in User object... or a custom object. I don't think Java or anyother implementation has other way to do it. If you mean a setting only applied during a session scope, then you use the way mentioned above.

 

 

If you wonder why HttpSession#setAttribute is not accessible, you should know the View State mechanism used in SFDC... all values in the controller are actually stored in your browser (HTML), not "a server" nor "all servers"...

Message Edited by ThomasTT on 09-16-2009 11:01 AM
TehNrdTehNrd

I've used a custom object for something very similar to this that saves values for a given user whenever they return to a visualforce page.

 

This idea might also be useful, http://ideas.salesforce.com/article/show/10097101/Allow_access_to_read_and_write_cookies_from_VisualForce_Controller

Message Edited by TehNrd on 09-16-2009 02:50 PM
Koen (BvD)Koen (BvD)
Thank you both for your reactions. It confirms what I already feared. Cookies seem like a good idea. I will probably try to make a component as you suggest.
gv007gv007

Koen,

         Did you got any sucess using cookies,am also travelling in same boat.

Thanks

Gopi

Koen (BvD)Koen (BvD)
yes I did, and it works, but I would recommend to check the new stuff included in the 17.0 release. I seem to have seen something in the list about user settings, so you might not need to use cookies.