Post by bfr on Nov 19, 2005 21:19:58 GMT -5
This entire tutorial assumes your asp.net applications use Visual Basic for their page language
Well, assuming you already know about body, local, and global variables, there are some "super" global varaibles out there - sessions and application-variables.
Sessions
Sessions are used to carry information form page to page. They keep there same value from one page to the next.
Making them:
Session("MySession") = 100
Note: You don't specify the type of variable a sessiob variable is by using "As vartype". They get their data type from what you store in them (it treats"hello" as string, etc.)
You can access session variables pretty much the same way:
Session("MySession")
The above returns the value of MySession.
Application Variables
Application variables are universal; only one exists regardless of how many people use it. An application variable show the same value, whethere Bob or Joe, on different computers, are viewing it in their browser.
You may lock or unlock application variables. When an application variable is locked, NO OTHER SESSIONS CAN CHANGE IT. Unlock makes it changable by other sessions.
Example:
Application.Lock
Applicarion("HitCounter") = 0
Application.Unlock
(Yes, Application variables are god for hit counters)
In case you still don't understand
I hope this example clarifies things.
If 10 people are on your website, there are 10 copies of each of your sessions such as "MySession". Even with 10 people on your site though, only ONE copy of "HitCounter" exists.
I hope you learned form hit, post comments, things you still don't understand, etc.
Well, assuming you already know about body, local, and global variables, there are some "super" global varaibles out there - sessions and application-variables.
Sessions
Sessions are used to carry information form page to page. They keep there same value from one page to the next.
Making them:
Session("MySession") = 100
Note: You don't specify the type of variable a sessiob variable is by using "As vartype". They get their data type from what you store in them (it treats"hello" as string, etc.)
You can access session variables pretty much the same way:
Session("MySession")
The above returns the value of MySession.
Application Variables
Application variables are universal; only one exists regardless of how many people use it. An application variable show the same value, whethere Bob or Joe, on different computers, are viewing it in their browser.
You may lock or unlock application variables. When an application variable is locked, NO OTHER SESSIONS CAN CHANGE IT. Unlock makes it changable by other sessions.
Example:
Application.Lock
Applicarion("HitCounter") = 0
Application.Unlock
(Yes, Application variables are god for hit counters)
In case you still don't understand
I hope this example clarifies things.
If 10 people are on your website, there are 10 copies of each of your sessions such as "MySession". Even with 10 people on your site though, only ONE copy of "HitCounter" exists.
I hope you learned form hit, post comments, things you still don't understand, etc.