How can I make a variable static (or “global”) in Classic ASP?

前端 未结 2 1217
走了就别回头了
走了就别回头了 2021-01-12 22:55

I want to make my variable static or \"global\" - so the same effect as static in .NET; every session that accesses it gets the same result, and if one session modifies it i

2条回答
  •  醉酒成梦
    2021-01-12 23:48

    using a session variable

    Session("myVariableName") = "my new value"
    

    the scope will be the user...

    if you want to wide the scope to ALL users that are in the website, then you use an Application variable

    Application("myVariableName") = "my new value"
    

    you can reset or handle this in the global.asa file as well

    This is a common thing to do:

    global.asa file:

    
    

    default.asp file:

    
     
     
     
      

    There are <%response.write(Application("visitors"))%> online now!

提交回复
热议问题