如何在vb.net中删除Cookie /会话刷新页面

时间:2019-07-11 16:03:23

标签: vb.net

我具有将用户重定向到页面刷新登录名的逻辑,但是即使会话期满后,我仍会检查标头,并且密码和用户名仍然存在。有人可以解释一下我如何为此清除会话/ cookie吗?

我已经尝试过Session.Abondon()和vb.net的新手,所以我现在还不熟悉如何使用它来管理Cookie。

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache)
        Response.Cache.SetCacheability(HttpCacheability.Private)
        Response.Cache.SetCacheability(HttpCacheability.Server)
        Response.Cache.SetNoStore()
        hiddenMaxRecords.Value = objSettings.MaxRecords
        hiddenStudyFilter = objSettings.StudyFilter


    End Sub

    '4.2.2 BF 12761 Prevent new session when page is refreshed
    Protected Overrides Sub LoadViewState(ByVal savedState As Object)
        Dim AllStates As Object() = savedState
        MyBase.LoadViewState(AllStates(0))
        _refreshState = Boolean.Parse(AllStates(1))
        _isRefresh = _refreshState = Session("__ISREFRESH")
    End Sub
    '4.2.2 BF 12761 Prevent new session when page is refreshed
    Protected Overrides Function SaveViewState() As Object
        Session("__ISREFRESH") = _refreshState
        Dim AllStates() As Object = New Object(2) {}
        AllStates(0) = MyBase.SaveViewState
        AllStates(1) = Not (_refreshState)

        Return AllStates
    End Function

会话在20分钟后过期,但是如果用户刷新页面,有时他们会自动登录,我希望他们必须在刷新页面时登录,并且还希望从cookie /会话中删除标头。

0 个答案:

没有答案