1
我創建了一個cookie並設置了正確的過期時間,但是當我去更新cookie並使用調試器檢查它時,失效消失了。到底是怎麼回事?爲什麼cookie過期消失?
' Cookie Helper: Updates cookie with the selected source ids
Protected Sub UpdateCookieFor(ByVal cookieName As String, ByVal sourceIds As String)
' Update cookie if it exists
If Request.Cookies(cookieName) IsNot Nothing Then
Response.Cookies(cookieName).Value = sourceIds
End If
End Sub
' Cookie Helper: Create cookie
Protected Sub CreateCookie(ByVal cookieName As String, ByVal sourceIds As String)
' Create cookie if it does not exist
If Request.Cookies(cookieName) Is Nothing Then
Response.Cookies(cookieName).Value = sourceIds
Response.Cookies(cookieName).Expires = DateTime.Now.AddYears(10)
End If
End Sub