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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting user if session times out

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
What is the best way to redirect a user back to the login page if there session times out? I have a framed application that the user enters into after logging into a non-framed page.

I have been experiencing that when the user's session times out, they get a server error in the frame that they were trying to access. I need to avoid this at all costs. Thanks

Brian regards,
Brian
 
create a global.asa and in the Session_OnEnd sub do the redirection. liekt his

Sub Session_OnEnd()
Response.Redirect "page to be direct to"
End Sub

A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
You can also set a session variable at login such as session("username") and test for that value at the top of every page. If its not found then redirect to login. This also handles anauthorized users.
 
Thank you. I tried doing the second suggestion, but with frames it gets tricky because I've experienced issues with all frames containing the login page. Not a pretty sight.

Brian regards,
Brian
 
Hi Brian
just add this one line to the head section of your asp script
<META HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;x; URL=test1.html&quot;>
where x=Session time out in seconds and test1 is the page you want the users to be directed.
Hope this works well
Regards
Tushar
 
Can I specify a target with the page to redirect to, otherwise, it will replace the login page in the current frame? Thanks

Brian regards,
Brian
 
That is why I recommended the global. does that not work for you? A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I was just commenting on the other post. I have it set up the way you said in the global.asa

Thanks for following up. regards,
Brian
 
sorry, it just sounded like you were still looking for a solution. A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Did the global.asa solution work? I thought that the response object was not available there (so, no response.redirect).

On your non-framed page, you should write a javascript like.

<script>
if (top.length != 0){
top.location = self.location
}
</script>

Excuse my script if it has errors, I'm a little rusty in JavaScript -- Just trying to help... LOL [ponder]
 
there's a fine line to that being correct and not correct.
No, not all response ojects are not available in the global. response.redirect can be used but only in certain ways. From my poor memory I believe you are only restricted when trying to write out of the global. cookies can also be utilized I believe. never attempted though. A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top