[Webinar] Streamline your web hosting managementRegister Today

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

using Session_OnStart !

I try the store something in the session during the start of a users' session.

I placed this code in the global.asa:
Sub Session_OnStart
      Session("id") = "test"
End Sub

But then when i try to get this id later, it's appears to be empty!!
And no the session hasn't been expired because it expired after 20 min...

Do you no what's happening??
1 Solution
How are you trying to recover this value?  It must be from within the same user session.

What I would do is to create a page which dumps all the variables, e.g.,

for each key in Session.Contents
   response.write key & " = " & Session(key) & "<br>" & vbcrlf

for each key in Application.Contents
   response.write key & " = " & Application(key) & "<br>" & vbcrlf

and run it after one of your pages to be sure what is happening.  If you don't get any variables, perhaps your global.asa is not firing for some reason (it could be in the wrong place).

Not that I think you don't know what you're doing but I've seen this before:

Are you trying to use that variable through ASP or through scripting?  The seesion object only exists on the server side, so if you refering to it on the client side (scripting) the variable will come up empty.

If you are refering to it form the server side, sorry I can't help you out...

Good luck
HI Rick,

Have you disabled cookie features in your browser?..or did your browser support cookies?  Session variables can only be used if your browser support cookies and its feature is turned on

To Check your browser if it supports cookies:


  <meta http-equiv="refresh" content="5;URL=test.asp">
<% on error resume next
   Session("ID") = "Hello"


<% if IsEmpty(Session("ID")) then
      Response.Redirect "NoCookie.asp"
   else         Response.Redirect "AllowCookie.asp"
   end if


in page1.asp you give the value to session var and the page automatically refresh after 5 seconds and bring you to test.asp. If your browser doesn't support cookie then your Session var is empty.  

Note: if you use global.asa then you can ommit page1.asp and directly go to test.asp as it will be default page

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

rick_mulderAuthor Commented:
TTom ,
you've seem to be right!
I also tried it with an application variable and this one was also empty when i requested it in an ASP Page.
It seems the global.asa is not functioning properly. You said something about a wrong location where should it be then. It's now on the same level as my asp-pages.
I really need to use this global.asa so please give me some advise...thanks
oh almost forgot this is the code i tried to get the application variable:
in the global.asa --> Application("test")="12345"
in my ASP-page --> Response.Write("value= "&Application("test"))

You need to be sure that the directory containing the global.asa is configured as an application.  Check this out in MMC (Internet Service Manager).  Under the Properties for the directory, the "Virtual Directory" tab should have a section for "Application Settings".  The application portion should be "active", i.e., not "grayed out".  If it is, one of the buttons should be labelled "Create" (instead of "Remove"), and you should create the application.

Another clue will be the icon for the directory in MMC (it should be something like an open box.

The other potential problem is if the directory is a subdirectory of another application.  If that is the case, either the global.asa for the other directory (or none at all if there is none) might be firing.

Do you have another project that seems to be working?  If so, try adding the variable to its global.asa and the test page to its pages.

If you are using Visual InterDev, it is generally pretty good about the configuration thing, so you might want to create a new project, and do it that way to get things running.

Good luck.


rick_mulderAuthor Commented:

Thank you very much for your very clear answer. You were right the application settings where grayed out. Although i didn't mean what they ment. Strange that when i create a project this isn't enabled automaticly..

But again i'm very happy it works now :)
Glad to be of assistance.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

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