Using Global.asa
page 1 of 4
Published: 17 Oct 2003
Unedited - Community Contributed
An article that briefly touches over what Global.asa is, how to use it and some examples of what it can do for your website.
by . .
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 26953/ 54

What is it?

Using Global.asa


Published 12/12/01


When working with ASP pages, you've probably used the session object to store variables that you want to use throughout your website. But what if you want to store the same variables forever, like connection strings or objects that you use over and over? What if you want to store variables when a session begins so you can store things like the time that user logged on? You can now do this (well, you always could actually) with Global.asa. This article will teach you about what Global.asa is, what to use it for and what not to use it for.

What is it?

Before I tell you, I must get some terms clear -

Application - An application (in ASP terms) is basically your asp site. Usually this is a virtual directory or maybe the whole thing. An application starts when the web server starts and ends when the web server stops. Which means that whatever variable you put in to start when the application starts (we'll cover that soon) won't stop till it stops.

Session - A session is from the time that a user starts looking at your site to the time he/she stops. Session is kept track of by a cookie on the user that gets deleted when the user closes his/her browser. All session data is stored on the server.

Now that we've got that out of the way -

Global.asa is a file that goes in the root directory of your site (or virtual directory) and whenever your application is started or stopped or whenever a user comes onto your site or leaves your site it gets activated. That is a pretty ugly description of it but that's it. The main purpose of it is to store information in Application variables and Session variables when the program is started.

If you didn't use Global.asa and wanted to store Application variables, then you would need to have created a file that created them and run that file when the app started and run it again if it restarted, the same with session variables. You generally don't know where a user comes into your site and if you want to assign session variables then you would have to create the same code on every page to check and create those variables. Global.asa eliminates this. When a user logs onto your site, wherever he/she is they get the variables automatically, whenever the application is started the variables are assigned automatically.


View Entire Article

User Comments

Title: exceeeeeeeeeeeeelent   
Name: jiji
Date: 2005-03-09 9:32:41 AM
this was the best explanation of for some one who is a beginner and was very helpfull
thank you for saving our neck
Title: Global.asa   
Name: P.Prathiba
Date: 2005-02-19 1:02:16 AM
This information is very useful for me.
Title: Well Done   
Name: Rizwan
Date: 2005-01-15 4:40:40 AM
Great Help from your site.

Keep it up! This type of help are very useful for newbies and sometimes for lazy professionals. lol...
Thanks Mr. Author!
Title: Global   
Name: Raj
Date: 2005-01-12 10:28:21 AM
This information is quiet useful.
Title: New User   
Name: Mollie...
Date: 2004-10-27 10:48:09 PM
Thanks! Your Article helped me out....
Title: Global ASA   
Name: Tonya
Date: 2004-10-24 11:36:05 AM
This information is GREAT. Expecially your picture on Virtural and Non-Vertual directories. I have created a small application, created a Global ASA to set a variable to current date. I then created an asp page which will display text along with the date. When I run the page in the browser, it displays my text but not the date. My question is, do I need to turn something on in order for a Global asa to execute?

Thanks for your help.
Title: hi jaan   
Name: Mehr
Date: 2004-09-12 3:42:13 AM
i like it this way...keep going...:p
Title: Global.asa   
Name: Niranjan
Date: 2004-08-30 6:16:07 AM
THis is very usefull artickle.I was confused with this becuse i was developing the web site without using this.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-05-29 7:31:18 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search