rick_mulder
asked on
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??
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??
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
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:
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
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
ASKER
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'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"))
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 :)
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.
Tom
Tom
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