Solved

How do you set Global variables in classic ASP pages?

Posted on 2011-03-08
3
401 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

786 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