Public Variables and Classes in ASP
I want to declare a variable that I can use in different parts of the application like we use variables in VB .NET
I would appreciate it very much if somebody could explain to me how to implement that.
Thank you very much and I appreciate your kindness.
Jalamang
Re: Public Variables and Classes in ASP
Variables on a web page are very different to variables in a vb application..
I think the best way to describe it is.. Every time a web page is requested, the application starts up (with command line variables) processes the information, displays an output and ends.
of course the 'App' is running all the time, but it is often best to consider each page request this way. So trying to define global variables that you can keep data in between pages is not a viable option, as you'll have to monitor each individule user on the site and store global variables for each one..
Best bet is to look into using session cookies...
Code:
Get a Cookie
UserId = Request.Cookies("Site")("UserID")
Set a Cookie
Response.Cookies("Site")("UserID") = UserId
Response.Cookies("Site").Expires = Date.Now.AddMonths(6)
as these store your Global Variables on the Web browser itself and you can access it from any page on the site, and they are specific to each user...