Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

redirect user to timeout page after timeout

Hi,

I know this question has been asked many times, but ater reading all the articles, I'm still confused how to do it.  

I'm aware this can be placed on each page to redirect user to timeout page

if Session ("test") = "" then
   Response.Redirect ("timeout.asp")
end if

However, I'm not sure where to put the session variable.  I heard it should be placed in global.asa. But how?
 

Qn1: How do I create Global.asa? Using notepad?  Dreamweaver?   Where to put this file?  
Qn 2:  Is there any simpler way to achieve this without adding global.asp?  I appreciate the simplest solution.

Pls let me know step by step.  I'm still considered a novice in ASP.
 




0
limhodav
Asked:
limhodav
  • 4
  • 3
1 Solution
 
GawaiCommented:
Global.asa
open up notepad and save it as "Global.asa" in notepade use double quote (") to save asa or asp file otherwise windows will save it as Global.asa.txt



<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart

                      Application("visits") = 0
            Application("Active") = 0            
                        
End Sub

Sub Session_OnStart
      Session("Start") = Now ' here is the name of session
      Application.lock
      Application("visits") = Application("visits") + 1
      intTotal_visitors = Application("visits")
      Application.unlock
      Session("VisitorID") = intTotal_visitors


      Application.lock
      Application("Active") = Application("Active") + 1
      Application.unlock
End Sub

Sub Session_OnEnd
      Application.lock
      Application("Active") = Application("Active") - 1
      Application.unlock
End Sub


0
 
limhodavAuthor Commented:
Thanks.  I have cut and paste your codes into global.asa n placed them in my root directory.

I also tried to show the session "start" and "visitorID"  in my main page after loggin in, but it is not showing. Why?  It seems to me global.asa is not being read by my application.   Wrong directory?

Another qn:
If I want to use <% Session.Timeout = 1 %>  (1 min for testing purposes) , where do I place this code?  Global.asa or another .asp file?    
0
 
limhodavAuthor Commented:
Let me rephrase.

If I use this code in my main page,  I will be immediately redirect to that page upon login. no matter how long the session.Timeout  

<% If Session("Start") = "" Then
      Response.Redirect Timeout.asp
     End If
%>

This means that Session("Start") still has the value of "" 

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GawaiCommented:
without global.asa file your session wil work in asp

one.asp
<%
Session("Start") = "MySessionValueHere"
Session.Timeout = 1
%>

<a href=two.asp>Next page</a>


two.asp

<% If Session("Start") = "" Then
      Response.Redirect Timeout.asp
     End If
%>
0
 
GawaiCommented:
two.asp
<% If Session("Start") = "" Then
      Response.Redirect Timeout.asp
     End If
%>

Session Value is : <%=Session("Start")%>
0
 
GawaiCommented:
if u have already saved my global.asa in root then remove that file or change my one/two.asp code to :

one.asp
<%
Session("SessionName") = "MySessionValueHere"
'Session.Timeout = 1
%>

<a href=two.asp>Next page</a>

two.asp

<%
If Session("SessionName") = "" Then
      Response.Redirect "Timeout.asp"
ELSE
      response.write "Session Value is : " & Session("SessionName")
End If
%>
0
 
limhodavAuthor Commented:
Thanks a lot for such simple steps.  

I substitute one.asp with my login page and two.asp with the rest of the pages and it does work!  
I have also deleted global.asa from the directory.

But I still don't understand why global.asa doesn't work :-(
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now