Solved

How do you set Global variables in classic ASP pages?

Posted on 2011-03-08
3
407 Views
Last Modified: 2012-05-11
I need to set variables in an ASP app that are set to static values. So that when the app switches between pages via POSTs and GETs etc. it can still call them. How do I do this
0
Comment
Question by:Lico_w
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35069737
You would have to use either the Session (user scoped) or Application (application scoped) variables:
<%
     Application("SomeGlobalValue") = "someValue"        '// scoped to the application
     Session("SomeUserValue") = "someValue"               '// scoped to the current user
%>

Open in new window

0
 

Author Comment

by:Lico_w
ID: 35069831
What about if its an array or number?

Also how would you then call it in the code?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35069855
You can store arrays and numbers in there too. ASP is implicitly typed so as long as you know what type of data you are storing you're good to go.

To pull data back out is as simple as:
someGlobalValue = Application("SomeGlobalValue")
someUserValue = Session("SomeUserValue")

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question