Session Variables and Static Variables

C

cobus.lombard

I have found it very easy to have a Helper class that has static
members which access Session Variables. For example:

public class HelperClass
{
public static doCustomer CurrentCustomer
{
get
{
if(HttpContext.Current.Session["Current_Customer"] == null)
CurrentCustomer = new doCustomer();

return (doCustomer)
HttpContext.Current.Session["Current_Customer"];
}
set
{
HttpContext.Current.Session["Current_Customer"] = value;
}
}
}

Is this thread safe? Will each user of the Application still have his
own instance of doCustomer, even though it is accessed via an
Application Wide static member? What is the best practice regarding
Thread Safety, Session Management and Static Members?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top