+ Start a Discussion

sessions in visual force (new to visual force)

Is there a concept similar to http sessions in visual force. For instance how is a shopping cart type of functionality achieved in visual force where in the shopping cart needs to be preserved in the middle tier across several pages without storing to the database and storing to the DB only on submission in the final page. I read about building a wizard using  some variablesin the controller to store references to objects we want to preserve. This seems a bit odd and was wondering if that was the only way to implement a wizard/shopping cart.

Imran MohammedImran Mohammed

There is no session concept in visualforce. The best way to achieve this is to store the details in the object and in the end save it.







By default anything variable on the controller is carried across "Requests". Unlike J2EE, in visual force as long as you are on the visual force page, the variables defined/initialized in the controller are carried across requests. If you don't want them to carry across requests, you have to use the "Transient" keyword.


Visual force also has limits on how much data you can have in your View State. The max limit is 128K of view state data.


Cookie support released with Summer 10 would be a perfect fit for something like this.