0
我想使用计时器删除会话变量。我有这个班。是否有可能用定时器删除会话变量?
Public Class SessionKiller
Private WithEvents mclsTimer As Timer
Private mstrSessionKey As String
Public Sub New(ByVal lstrSessionKey As String)
mstrSessionKey = lstrSessionKey
mclsTimer = New Timer(3000)
mclsTimer.AutoReset = False
mclsTimer.Start()
End Sub
Private Sub OnTimedEvent(ByVal lobjSource As Object, lclsEvent As ElapsedEventArgs) Handles mclsTimer.Elapsed
HttpContext.Current.Session.Remove(mstrSessionKey)
End Sub
End Class
但是current
变量不算什么。这样可以删除会话变量吗?
请在您获取/创建会话的位置添加代码 – theBugger