This is really not an answer to your questions, but you might want to
refactor the code design.
Session variables are nothing more than "fancy" global variables. And just
like the way you might avoid the use of global variables in a normal
application, the same reasoning should be applied to session variables.
That is not to say that global/session variables are not important -- they
have their place -- but it is important to be able to rationalize why you
use them rather than just saying something like "they are convenient."
Having said that, here is my take on your question.
What do you mean "keep track of"? Do you mean being able to know what parts
of code are setting a particular variable or simply that you want a list of
session variables in use? In the past, if I wanted to use session
variables, I have often encapsulated the getting and setting behind some
other class that centralizes the action. Essentially there would then be
only one place in the entire code that sets or gets the value directly from
the session (that is there was only one call to Session["..."]). By doing
this, you can 1) centralize access to the variable, 2) be able to group
related session variables together, and 3) Be able to enforce consistency
like suppose that variable "foo" could only be set if variable "bar" is
null, then properties could help enforce that.
> Hi there,
>
[quoted text clipped - 6 lines]
>
> Alan
Alan Wang - 28 Oct 2005 20:02 GMT
>>Do you mean being able to know what parts
of code are setting a particular variable or simply that you want a list of
session variables in use?
Probably both. Sometimes I just lost keep track of where I used this Session
variable and why use this session variable especially when you didn't touch
that code for a while. For regular variable, I can use "go to definition"
and then be able to find where I defined this variable and data type. But I
can't do it with Session variable. That's something really bothers me. Do
you have any solution or suggestions for that.
Thanks in advanced
Alan
> This is really not an answer to your questions, but you might want to
> refactor the code design.
[quoted text clipped - 30 lines]
>>
>> Alan
Peter Rilling - 28 Oct 2005 20:23 GMT
When I need to find session variables, I simply search the whole project for
the string "session[". Then I catalog all the variables that I find and
where they are accessed.
>>>Do you mean being able to know what parts
> of code are setting a particular variable or simply that you want a list
[quoted text clipped - 51 lines]
>>>
>>> Alan