Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session OnStart in Global.asa

Status
Not open for further replies.

allyeric

Programmer
Mar 14, 2000
104
0
0
CA
Visit site
I want to initialize a few session variables in the global.asa file.&nbsp;&nbsp;Below is my code - when I try to print the &quot;Index&quot; variable in my asp page, there is no value.&nbsp;&nbsp;Can someone please let me know where I have gone wrong?<br><br><br>Global.asa:<br><br>&lt;SCRIPT LANGUAGE=VBScript RUNAT=Server&gt;<br><br>Sub Session_OnStart()<br> Session(&quot;Number&quot;) = &quot;&quot;<br> Session(&quot;PictureID&quot;) = &quot;&quot;<br> Session(&quot;Index&quot;) = 1<br> Session(&quot;number&quot;) = &quot;&quot;<br>end sub<br><br>&lt;/SCRIPT&gt;<br><br><br>ASP page:&nbsp;&nbsp;this is how I called the variable:<br><br>Index = Session(&quot;Index&quot;)<br>response.write Index<br><br><br>Thanks<br><br>
 
At my company we never use the global.asa, because most of the time it doesnt even work, thats all I can tell you. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Global.asa is very dependable, and works consistently, despite Karl's experiences. However, you must take the time to understand how it works, and why you might not get the results you expect.<br><br>The most obvious reason why the session variables might not work is if cookies are disabled.&nbsp;&nbsp;Session variables are stored in cookies, so if cookies are disabled,&nbsp;&nbsp;the session variables simply won't work.&nbsp;&nbsp;Another possibility is that your web site is set to disable session state.&nbsp;&nbsp;This isn't the default, so someone would have had to change it for this to be the case.<br><br>If neither of the above is the problem,&nbsp;&nbsp;it's probably just an incomplete understanding of how global.asa works.&nbsp;&nbsp;It's not as simple as it looks at first glance.&nbsp;&nbsp;I'd suggest taking a look at these resources,&nbsp;&nbsp;and then, if you're still having problems, let us know.<br><br><A HREF=" TARGET="_new"> HREF=" TARGET="_new"> HREF=" TARGET="_new"> HREF=" TARGET="_new"> Did you get your Javascript routine to work?<br><br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
thanks nick - I have session variables in other pages that are not being initialized from the global.asa, and they work fine, so obviously its an incomplete understanding.&nbsp;&nbsp;I will look up thoses resources you suggested.<br><br>And no, I still didn't get that javascript routine to work&nbsp;&nbsp;-&nbsp;&nbsp;taking the day off from that one&nbsp;&nbsp;:eek:)<br><br>
 
Our reason is probally due to the way IIS is setup , I myself havent really tried it, but one time it wasnt working and my other co-workers just told me not to use it. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top