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??
rick_mulderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TTomCommented:
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
next
%>

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

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).

Tom
0
TikaCommented:
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
0
HencahCommented:
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:

page1.asp:

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

test.asp:

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



</html>

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

Regards
cah
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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"))
0
TTomCommented:
Rick:

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.

HTH,

Tom
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rick_mulderAuthor Commented:
Tom,

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 :)
0
TTomCommented:
Glad to be of assistance.

Tom
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.