i want to give facility for my website in which user will idle for some minutes it will automatically session destroy.
so what can i do and what is the solution for it.
please give answer...
Thanks in advance...
Mitesh
Log off automatically after some idle time
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kunal VaishyaRank #990 · 2K reputationPosted Apr 28, 2012, 3:47 AM EDT
This is VB Code you have to convert it into C#
Private Declare Function GetLastInputInfo Lib "user32.dll" (ByRef plii As LASTINPUTINFO) As Boolean
Private Function GetIdleTimeForUser() As Long 'Kunal 29032012
1: Try
2: Dim lastone As New LASTINPUTINFO()
3: lastone.cbSize = CUInt(Marshal.SizeOf(lastone))
'lastone.cbSize = CULng(Marshal.SizeOf(lastone))
4: lastone.dwTime = 0
5: Dim idleTime As Long = 0
6: Dim tickCount As Long = Environment.TickCount
7: If GetLastInputInfo(lastone) Then
8: idleTime = tickCount - CLng(lastone.dwTime)
9: idleTime = idleTime / 1000
'Debug.Print(idleTime)
10: Return idleTime
11: Else
12: Return 0
13: End If
14: Catch ex As Exception
16: End Try
It will give you last input time you can set difference and set your logic in timer
MItesh Machhi30 reputationPosted May 2, 2012, 4:55 AM EDT