QUERY: variable scope in ASP pages?

J

John

Hi all,
Can anyone tell me if its possible when using ASP pages, to define a
variable which is available to ALL asp pages in the site?

Would I need to use a 'global.asa' file, and if so, how do I define
the variable in it, and then reference it in other asp pages.

TIA.
 
M

Mike Mueller

Would a session variable work?

John wrote:
: Hi all,
: Can anyone tell me if its possible when using ASP pages,
: to define a variable which is available to ALL asp pages
: in the site?
:
: Would I need to use a 'global.asa' file, and if so, how
: do I define the variable in it, and then reference it in
: other asp pages.
:
: TIA.
 
M

MD Websunlimited

Hi John,

To all visitor sessions or global to all pages used within a visitors session?
 
J

Jon Spivey

Hi,
You can set an application variable which is the same for all users
application("Whatever") = "something"
or to have the variable different for each user
session("whatever")="something"
 
J

John

Where would that application variable be set?....in a global.asa file?
Also, I'm not 100% certain what constitutes an application in the web
sense?
Also, if an application variable is set this way, would I be able to
change its value in other pages?
TIA.
 
M

Mike Mueller

John,

An application is a group of asp pages working together
Application variables are created in the global.asa file.
An application is a group of asp pages working together
Application variables are global and affect all users
Application variables can either last for a session or as
long as the application is running.

A Session occurs when a new user accesses an asp page
Session variables can be created in either the gloabl.asa
file or in any asp page
Session variables can be changed in any asp page
Session variables affect only the one user
A Session ends when the user navigates out of the
application and the timeout expires- default is 20 minutes

Good tutorial on this:
http://www.karachiplus.com/tutorial/asp.asp

Mike


: Where would that application variable be set?....in a
global.asa file?
: Also, I'm not 100% certain what constitutes an application
in the web
: sense?
: Also, if an application variable is set this way, would I
be able to
: change its value in other pages?
: TIA.
:
: On Mon, 13 Dec 2004 21:06:14 -0000, "Jon Spivey"
<[email protected]>
: wrote:
:
: >Hi,
: >You can set an application variable which is the same for
all users
: >application("Whatever") = "something"
: >or to have the variable different for each user
: >session("whatever")="something"
:
 
S

Stefan B Rusynko

Consider using an ASP include page w/ global variables on all pages instead of editing global.asa
- any changes to your db will probably redo your global.asa and you may lose your edits

--




| Thanks Mike,
| I think thats cleared it up a bit for me.
|
| On Mon, 13 Dec 2004 17:44:23 -0600, "Mike Mueller"
|
| >John,
| >
| >An application is a group of asp pages working together
| >Application variables are created in the global.asa file.
| >An application is a group of asp pages working together
| >Application variables are global and affect all users
| >Application variables can either last for a session or as
| >long as the application is running.
| >
| >A Session occurs when a new user accesses an asp page
| >Session variables can be created in either the gloabl.asa
| >file or in any asp page
| >Session variables can be changed in any asp page
| >Session variables affect only the one user
| >A Session ends when the user navigates out of the
| >application and the timeout expires- default is 20 minutes
| >
| >Good tutorial on this:
| >http://www.karachiplus.com/tutorial/asp.asp
| >
| >Mike
| >
| >
| >| >: Where would that application variable be set?....in a
| >global.asa file?
| >: Also, I'm not 100% certain what constitutes an application
| >in the web
| >: sense?
| >: Also, if an application variable is set this way, would I
| >be able to
| >: change its value in other pages?
| >: TIA.
| >:
| >: On Mon, 13 Dec 2004 21:06:14 -0000, "Jon Spivey"
| ><[email protected]>
| >: wrote:
| >:
| >: >Hi,
| >: >You can set an application variable which is the same for
| >all users
| >: >application("Whatever") = "something"
| >: >or to have the variable different for each user
| >: >session("whatever")="something"
| >:
| >
|
 
J

Jon Spivey

Hi John,

You can set or change an application variable anywhere you like - just as
you would any variable. However in most cases you would set it in
global.asa, it lasts from when the server is booted up until either the
server is re-booted/shut down or you change any pages in the app. You'd
probably want to set the variable when the application starts which you'd do
in global.asa like this
sub application_onstart
application("whatever") = "something"
end sub
 

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

Top