SessionFacade

It is very common in a web application to store information in the session object, a tipical code snippet is shown bellow:

// put data in session
Session[ "myData"[ = myData;

// do something

// retreive data from session
myData = (Data)Session["myData"[;

The previous code is error prone and requires a cast each time you want to access to session. To prevent these situations when interacting with the session object, create a static SessionFacade class, with methods to provide access to the information you want to store in the session.

SessionFacade.SetData(myData);
SessionFacade.SetX(x);

// do something

myData = SessionFacade.GetData();
x = SessionFacade.GetX();

Last edited Apr 17, 2008 at 4:09 AM by nicolaz, version 7

Comments

No comments yet.