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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MItesh MachhiPosted May 2, 2012, 8:55 AM
Kunal VaishyaPosted Apr 28, 2012, 7:47 AM
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