473,804 Members | 3,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting Session Timeout

Hi. How can I detect if a user's session has timed-out? I'd like to be able
to redirect the user to a specified page in the event of session timeout.

Thanks!
Oct 2 '06 #1
7 2052
You can't.

All you can do on the server, is when there is a request after the timeout,
you can detect it is a new session (either because your session variables
are empty, or because IsNewSession returns true), and redirect then.

Or you can have a countdown running on the client in javascript that
redirects.

The server however cannot know that the client has timed out and send a
redirect down.

"Mike" <Mi**@discussio ns.microsoft.co mwrote in message
news:81******** *************** ***********@mic rosoft.com...
Hi. How can I detect if a user's session has timed-out? I'd like to be
able
to redirect the user to a specified page in the event of session timeout.

Thanks!

Oct 2 '06 #2
http://aspalliance.com/520

The ASP.NET HttpSessionStat e class provides a useful IsNewSession( ) method
that returns true if a new session was created for this request.

"Mike" <Mi**@discussio ns.microsoft.co mwrote in message
news:81******** *************** ***********@mic rosoft.com...
Hi. How can I detect if a user's session has timed-out? I'd like to be
able
to redirect the user to a specified page in the event of session timeout.

Thanks!

Oct 2 '06 #3
I have seen some javascript client-side solutions. You may want to look in
the HTML of one of your online account providers, such as a bank or credit
card company, to see an example of a javascript timeout (usualy located in a
..js script file). Otherwise though, there's no real way to know when the
event occurs because the client and server are disconnected the second the
client retrieves the final item for that page.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Mike" <Mi**@discussio ns.microsoft.co mwrote in message
news:81******** *************** ***********@mic rosoft.com...
Hi. How can I detect if a user's session has timed-out? I'd like to be
able
to redirect the user to a specified page in the event of session timeout.

Thanks!

Oct 2 '06 #4
Thank you, both, very much!

"Mike" wrote:
Hi. How can I detect if a user's session has timed-out? I'd like to be able
to redirect the user to a specified page in the event of session timeout.

Thanks!
Oct 2 '06 #5
Forgive me if Im wrong but doe'nt the global.asax file have a Session_ONEND
event handler that you can use a redirect within?

Just a thought

Damian
MCP
Oct 4 '06 #6
Apologies for my silly remark about global.asax earlier, what you could do is
use this in your page header:

<meta http-equiv="refresh"
content="300;ur l='checksession .aspx?redirUrl= currentpage.asp x'">

So when the refresh occurs pass your current page across, check the session
state as in the following page load method:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
If Not Session("whatev er") Then
Response.Redire ct("loggedout.a spx")
Else
Response.Redire ct(Request.Quer yString("redirU rl").ToString )
End If
End Sub

If it exists bounce them back to the original page, if not redirect to a
logged out page.

Thats what my banks uses by the look of it.

Easy Peasy.

Damian
MCP
Oct 4 '06 #7
Hi.

Doesn't the action of posting to checksession.as px actually keep the
session itself alive, voiding the test to begin with?
DieHardGuy wrote:
<meta http-equiv="refresh"
content="300;ur l='checksession .aspx?redirUrl= currentpage.asp x'">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
If Not Session("whatev er") Then
Response.Redire ct("loggedout.a spx")
Else
Response.Redire ct(Request.Quer yString("redirU rl").ToString )
End If
End Sub

If it exists bounce them back to the original page, if not redirect to a
logged out page.
Nov 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15473
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site | Properties | Configuration | Options | Enable Session State Session timeout 20 (3) within Global.asax.vb file - Session_Start subroutine can use Session.Timeout=x minutes or (4) within any web page, i.e., <web page>.aspx can use...
4
2766
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been lost and show an explanatory message before restarting the session. Rather than tagging a 'session in progress' flag on the end of every request querystring I'd like to detect it using data sent in every request. One idea I had was that when...
3
7385
by: Simon | last post by:
Hi all, Any help with this would be much appreciated: I have a site where the session needs to timeout because of security concerns. I want to send the user back to the login page if the session is expired. Whats happening at the moment is that objects that exisit in the Session are being accessed when the session has expired.
11
3014
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
4
1660
by: Chris Newby | last post by:
I realize that I can handle "SessionEnd" from global.asax ... but it appears to me that this gets called without the context of a current web request. So given the following scenario: User logs in and session starts User is inactive longer than the session timeout setting Some thread, not associated with a request, detects the timeout and raises Session_End() The User comes back to the site presenting a timed-out session id ASP.NET...
4
9463
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change the forms authentication to be a large value for that page also. TIA - Jeff.
2
11181
by: runner7 | last post by:
Can anyone tell me if there is a way in PHP to determine when a session times out on the server or how many concurrent sessions there are in your application?
9
5577
by: timor.super | last post by:
Hi group, I've written a client/server application, using the dotnet sockets. In my server, I have a thread waiting for messages with : ret = currSocket.Receive(buffer, 1024, SocketFlags.None); When the client exits, I close the socket with a specific message (like "end") and the thread terminate in a proper manner, but If my client crashes, the server is still waiting for receiving data, and
3
7601
by: Sems | last post by:
Hi I'm using the Session_End event in the global.asax to detect if a users sessions has ended. Is there any way to tell if the session end is due to it being expired and not abandoned? I'm trying to show the user a popup if their session has expired due to a timeout. Whats the best way to do this?
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.