Creating a global variable in ASP

  • SPooja
  • Newbie
  • Newbie
  • SPooja
  • Posts: 7

Post 3+ Months Ago

Hoe can we have a global variable in ASP which can be used across pages......please help me out in this.....
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

Don't really know asp but you would probably have to send it along in the url, or store it in a file.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I agree, I think you will have to pass it along in the query part of the url which is the part after the ? Here is an example way of how you might call the url:

Code: [ Select ]
http://www.somesite.com/somepage.asp?queryinfohere


or you could store it in a cookie and simply read from the cookie when you load a new page.

I am not aware of any way with ASP or any other programming languages of passing a global variable from page to page. The reason being is because once you load the page the program basically ends then, its not ongoing. So you would somehow have to store the data and pass it along.
  • RichB
  • Guru
  • Guru
  • User avatar
  • Posts: 1121
  • Loc: Boston

Post 3+ Months Ago

You can store variables in the application or session objects. The application object is shared by all users but each user has a separate session object, so it depends on what you want to do.

You can use the Global.asa file to declare variables that can be accessed by every page in an ASP application by storing them in the application object . (You can also do a bunch of other things with Global.asa.)

I'd suggest reading the application, session and global.asa sections of the W3Schools ASP tutorial they have some good examples:

http://www.w3schools.com/asp/default.asp

I think you need to be careful about storing variables in the session object because there can be many session objects depending on the number of active users - in other words I think they can eat up memory.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

That would be another way you could store the information to pass it along. I am thinking that using a cookie would use less resources from your server, as you are putting all that information with the client then.

If the global variable is something that can be just placed at the beginning of all your ASP files I would just do that, but if you need to pass it along to your other pages then using sessions, cookies, or passing information along in queries might be an option for you.
  • SPooja
  • Newbie
  • Newbie
  • SPooja
  • Posts: 7

Post 3+ Months Ago

Bigwebmaster wrote:
That would be another way you could store the information to pass it along. I am thinking that using a cookie would use less resources from your server, as you are putting all that information with the client then.

If the global variable is something that can be just placed at the beginning of all your ASP files I would just do that, but if you need to pass it along to your other pages then using sessions, cookies, or passing information along in queries might be an option for you.



Actually i have got a dll file and i want to make a global object of a class of this dll file which can be used across asp pages.
Please guide me in this.......
Thanx... :roll:

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 71 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.