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