[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do you set Global variables in classic ASP pages?

Posted on 2011-03-08
3
Medium Priority
?
417 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
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…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.

650 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