467,911 Members | 1,376 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

Creating session variables in GLOBAL.ASA ???

Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference
in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is coming
up as "".

I'm obviously misunderstanding how this works... Can anyone point me the
right direction?

Eventually I'll need to access a database and I'm assuming that if I need to
connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd event
of the GLOBAL.ASA file.

Any help is appreciated!
Jul 19 '05 #1
  • viewed: 8519
Share:
14 Replies

"RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is coming up as "".
A few things to notice:

1st: DON'T MULTIPOST!!!!

2nd: I think "Session_OnStart" should be "Session_OnStart ()"

3rd: Check the location of global.asa. Must reside in the root of your
application.

4th: Make sure you can have a Global.asa file. If you're hosting on a free
provider like
brinkster.com you'll probably not be allowed to use custom global.asa files.

5th: You'd probably be better off referencing this as a boolean value. Even
though all values are stored as variants there are always type-casting
issues, also you'll probably find yourself making niggly little mistakes in
case-sensitivity if you store this in a string.
Eventually I'll need to access a database and I'm assuming that if I need to connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd event of the GLOBAL.ASA file.


No you won't: http://www.aspfaq.com/2053

Regards

Matt
Jul 19 '05 #2
Are you sure this global.asa is in a folder marked as an application? If it
isn't, it will use global.asa from the default webroot or the parent
application.

Are you sure sessions are working?
http://www.aspfaq.com/2057


"RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is coming up as "".

I'm obviously misunderstanding how this works... Can anyone point me the
right direction?

Eventually I'll need to access a database and I'm assuming that if I need to connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd event of the GLOBAL.ASA file.

Any help is appreciated!

Jul 19 '05 #3
I don't see why what you've written wouldn't work, however your database
paragraph is incorrect. You DON'T want to open a connection that way. You
may want to store the connection string in a Session variable, but you
should open and close database connections on the individual pages.

Is your global.asa file in the root of the web application?


"RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is coming up as "".

I'm obviously misunderstanding how this works... Can anyone point me the
right direction?

Eventually I'll need to access a database and I'm assuming that if I need to connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd event of the GLOBAL.ASA file.

Any help is appreciated!

Jul 19 '05 #4
Thanks for the quick reply.

The application variables are updating. I've got a "user" application
variable that updates fine in the same global.asa file.

In the GLOBAL.ASA file...
Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

In my ASP file...
<% response.write("LoggedOn = " & Session("LoggedOn") ) %>

....and it never displays anything except "LoggedOn="

P.s. Replying from home... That's why the different posting name.

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Are you sure this global.asa is in a folder marked as an application? If it isn't, it will use global.asa from the default webroot or the parent
application.

Are you sure sessions are working?
http://www.aspfaq.com/2057 "RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference
in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is coming
up as "".

I'm obviously misunderstanding how this works... Can anyone point
me the right direction?

Eventually I'll need to access a database and I'm assuming that if I need to
connect to that database, that I'll need to create the connection
in the Session_OnStart event and destroy the connection in the

Session_OnEnd event
of the GLOBAL.ASA file.

Any help is appreciated!


Jul 19 '05 #5
> The application variables are updating. I've got a "user" application
variable that updates fine in the same global.asa file.

In the GLOBAL.ASA file...
Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub


Then the individual users are not accepting sessions. Did you look at
http://www.aspfaq.com/2057 ?
Jul 19 '05 #6
> First, I DIDN'T! I CROSSPOSTED! I *DO* WATCH ALL OF THE GROUPS I
POSTED TO AND THEY ARE ALL RELATED.
Quit yelling. Two of the three groups you posted to do not exist on
msnews.microsoft.com, where most people get this feed from. If you use
msnews.microsoft.com as your news server, you'll get the same error that
everyone else gets every time they try to reply to your post.
Actually, it is... I didn't include the brackets in my news posting.


Always copy the exact code you're using, rather than transcribing (which can
lead to errors and miscommunications, like this one). Would you bring your
friend's car into the mechanic when yours won't start? They're both Civics,
right?
Jul 19 '05 #7
> As for the groups not existing.. I have used the msnews server and
find that it isn't as reliable as my own server. Very often the msnews
server will just sputter out and die and no posts appear for days.
You should still check that the groups you see and post only to those you
know others will see. Of course, you might not have known that, but please
keep that in mind in the future.

Also, it is very rare you need to cross-post, pick a group... if it's the
wrong one, people will direct you elsewhere.
I do appreciate the help.... Thanks!


Once again, did you even *LOOK* at http://www.aspfaq.com/2057
Jul 19 '05 #8

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29...
Some One wrote on 17 jul 2003 in microsoft.public.inetserver.asp.general:
Session("LoggedOn")="Y"


What is the sense of setting this in Global.asa ??

Wouldn't testing on the existence of a session ID give the same

results as testing on your Session("LoggedOn") ?

Session("LoggedOn")="Y" being ste AFTER testing for it is usefull as it can trigger special code in the first page of a session, or preventing someone to start browsing anywhere else but on the homepage. This last method should not be applied without a robots.txt file to keep googling

healthy.

Yes.. by itself this is silly, but I'm trying to figure out why it
doesn't work.

My intention is to create a session variable with a access level value
that will hide certain features, depending on it's value. This won't
work if all I ever get is "0".
Jul 19 '05 #9

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
As for the groups not existing.. I have used the msnews server and
find that it isn't as reliable as my own server. Very often the msnews server will just sputter out and die and no posts appear for days.
You should still check that the groups you see and post only to

those you know others will see. Of course, you might not have known that, but please keep that in mind in the future.
Actually, I did notice that they didn't exist on the MS server when I
arrived home and went looking for the groups, but there were postings
in at least one of the other groups, so I know others are using it.
Also, it is very rare you need to cross-post, pick a group... if it's the wrong one, people will direct you elsewhere.

I do appreciate the help.... Thanks!


Once again, did you even *LOOK* at http://www.aspfaq.com/2057


Yup... "How can I tell which version of MDAC I'm running?" Doesn't
seem really relevant to me.

I think you meant http://www.aspfaq.com/show.asp?id=2157 ... but none
of the comments on that page have helped with this issue.

I'm pretty sure it's just me doing something stupid, but I don't see
it.

Jul 19 '05 #10
Some One wrote on 17 jul 2003 in microsoft.public.inetserver.asp.general:
Yes.. by itself this is silly, but I'm trying to figure out why it
doesn't work.
It could be, that the session is not yet ready for its variables at that
time ?
My intention is to create a session variable with a access level value
that will hide certain features, depending on it's value. This won't
work if all I ever get is "0".


If you define the nonexistence [= zero string] of the sessionvariable as
maximum hide, same as level 17, it is possible.

In your protected pages:

<%
if session("accesslevel")="" then session("accesslevel")=17

if session("accesslevel")<8 then then response.redirect "noadmittance.asp"
%>

Global.asa problem solved ?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11
Evertjan had a thought. Why not (as a test) set up a page and set your
session variable there, to see if it's working. Then you'll know that it's
for sure global.asa
"Some One" <po********@127.0.0.1> wrote in message
news:na***********************@news2.calgary.shaw. ca...

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
As for the groups not existing.. I have used the msnews server and
find that it isn't as reliable as my own server. Very often the msnews server will just sputter out and die and no posts appear for days.


You should still check that the groups you see and post only to

those you
know others will see. Of course, you might not have known that, but

please
keep that in mind in the future.


Actually, I did notice that they didn't exist on the MS server when I
arrived home and went looking for the groups, but there were postings
in at least one of the other groups, so I know others are using it.
Also, it is very rare you need to cross-post, pick a group... if

it's the
wrong one, people will direct you elsewhere.

I do appreciate the help.... Thanks!


Once again, did you even *LOOK* at http://www.aspfaq.com/2057


Yup... "How can I tell which version of MDAC I'm running?" Doesn't
seem really relevant to me.

I think you meant http://www.aspfaq.com/show.asp?id=2157 ... but none
of the comments on that page have helped with this issue.

I'm pretty sure it's just me doing something stupid, but I don't see
it.

Jul 19 '05 #12
That helped a lot...

Not sure what I was doing wrong, but I moved my files to a new folder
and re-setup the webpage in IIS and it's working fine now.

I don't see any difference in the settings, but I'm not complaining.

Thanks guys!!!

"Tom B" <sh*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Evertjan had a thought. Why not (as a test) set up a page and set your session variable there, to see if it's working. Then you'll know that it's for sure global.asa

Jul 19 '05 #13
Can anyone help me how to make keyevents for richtextbox in javascript or
WYSIWYG editor

all i am working on a textarea where X number of char reaches in a line then
the function to move the next line with inserting break.
Julia Mark
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Are you sure this global.asa is in a folder marked as an application? If it isn't, it will use global.asa from the default webroot or the parent
application.

Are you sure sessions are working?
http://www.aspfaq.com/2057


"RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference
in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is

coming
up as "".

I'm obviously misunderstanding how this works... Can anyone point me the
right direction?

Eventually I'll need to access a database and I'm assuming that if I

need to
connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd

event
of the GLOBAL.ASA file.

Any help is appreciated!


Jul 22 '05 #14
Can anyone help me how to make keyevents for richtextbox in javascript or
WYSIWYG editor

all i am working on a textarea where X number of char reaches in a line then
the function to move the next line with inserting break.
Julia Mark
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Are you sure this global.asa is in a folder marked as an application? If it isn't, it will use global.asa from the default webroot or the parent
application.

Are you sure sessions are working?
http://www.aspfaq.com/2057


"RooLoo" <Ro****@Loo.Roo> wrote in message
news:lR***********************@news3.calgary.shaw. ca...
Hey all

In my GLOBAL.ASA file I'm trying to create a session variable for reference
in the various webpages of my site....

Sub Session_OnStart
Session("LoggedOn")="Y"
End Sub

When referring to Session("LoggedOn") on my various ASP pages, it is

coming
up as "".

I'm obviously misunderstanding how this works... Can anyone point me the
right direction?

Eventually I'll need to access a database and I'm assuming that if I

need to
connect to that database, that I'll need to create the connection in the
Session_OnStart event and destroy the connection in the Session_OnEnd

event
of the GLOBAL.ASA file.

Any help is appreciated!


Jul 22 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bonj | last post: by
3 posts views Thread by J. Ptak | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.