ASP session variable

C

carthegenian

I have created a session variable.... and i have to write code to check for
this session for each ASP webpage in my website....Is there a alternative...??


I do not want to repeat the same code for valid session.... in each page..
 
C

carthegenian

I wrote the following code in GLOBAL.ASA file

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Session_OnStart
if Session("name") = "" then
response.redirect "login.asp"
end if
End Sub
</SCRIPT>

and took off the individual "session check" code from each file......
this does not seem to work.... Is there anything wrong with the code above...
 
E

Evertjan.

=?Utf-8?B?Y2FydGhlZ2VuaWFu?= wrote on 17 nov 2006 in
microsoft.public.inetserver.asp.general:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Session_OnStart
if Session("name") = "" then
response.redirect "login.asp"
end if
End Sub
</SCRIPT>

This is overkill,
since when a session starts,
Session("name") = ""
ALWAYS!

So the same would be:

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Session_OnStart
response.redirect "login.asp"
End Sub
</SCRIPT>

The question is however,
if response.redirect is allowed in global.asa.

<http://www.w3schools.com/asp/asp_globalasa.asp>
says it can be done, and gives an example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,137
Messages
2,570,795
Members
47,342
Latest member
eixataze

Latest Threads

Top