views:

95

answers:

2

I need to have the ability to have a Global variable/class that stores some basic information about the currently logged in user including that user's preferences, security rights, UserID, etc. This information will be needed by any/every part of my application.

In the past I have either used a Public variable/class in a vb.net module for this purpose. I'm trying to get away from my old ways of doing things and was curious what people currently do for this functionality.

I am thinking a singleton or 2 regarding preferences and security but am not sure if that is the best way to go.

TIA

EDIT: I asked this when I was too sleepy last night. This is an n-Tier WinForms application.

+1  A: 

In my ASP .net web app, I store an object that contains login information for that user in the Session Cache. That is one way.

Russell
see: http://msdn.microsoft.com/en-us/library/ms178581.aspx
Thr4wn
A: 

If you want different "global variables" for each user, then sessions are the way to go (as Russell mentioned). If you want variables that are the same for every single user, then Application variables are what you want.

Thr4wn