• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

How do you set Global variables in classic ASP pages?

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
Lico_w
Asked:
Lico_w
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
Lico_wAuthor Commented:
What about if its an array or number?

Also how would you then call it in the code?
0
 
Carl TawnSystems and Integration DeveloperCommented:
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

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now