Results 1 to 6 of 6

Thread: global variables

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    How should I go about declaring global variables for my ASP pages? I want to have some variables that will be constant throughout the pages. Is there some way that I can store all of them in the same page and then include them with the other pages, like a VB module?

  2. #2
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281
    You should be able to use the global.asa file.

    Wait, let me clarify that a bit:
    You can create a session variable in the global.asa file so that every asp page will have access to it.
    Last edited by compuGEEK; Mar 30th, 2001 at 03:06 PM.

  3. #3
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    You could store them all in a file and use Server-Side Includes on each page to get it.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    Thanks guys for the suggestions

    compuGeek - how do I go about creating a session variable? I am new to ASP. I put

    <!-- include file "global.asa" -->

    in all of the files, and that seems to work, albeit a bit inefficiently.

  5. #5
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118

    Post

    My suggestion is try to avoid session variables, it is has lots of disadvantages, for more info check msdn.microsoft.com..

    Sonia

  6. #6
    Guest
    You create a session variable like this:

    Session("strUserName") = "bubba"

    You can change the value of a session variable at anytime.

    Some (potential) problems with session variables are;

    They are stored in memory, so if you have a lot of users connected at once and your session variables contain a lot of data, there could be performance issues;

    If the user disables cookies on their browser, session variables don't work;

    If you are using a web farm, and your re-directs contain the complete url (response.redirect "http://newasp.asp") rather than the logical path (response.redirect "../newdir/newpage.asp ") the session variables could be lost.

    Of course, these problems do not always occur, and there are other potential problems (which I'm sure somebody will point out) that may present themselves.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width