我正在使用一个大 cookie 的子键来存储多个帮助文本的隐藏状态。但是如果更新了单个子项,则所有其他子项都将被删除。我是否应该始终同时更新给定 cookie 的所有子键来解决这个问题?
这是我目前有问题的功能。
' Store cookie_value of cookie_name .
sub store_string( cookie_value , cookie_name )
' Sets cookie cookie_name to cookie_value.
response.Cookies( "UserSettings" )( cookie_name ) = cookie_value
response.Cookies( "UserSettings").Expires = datetime.now.adddays(365*10) ' 10 years. The hardware won't last that long!
end sub
' Retrieve stored cookie_name.
function restore_string( byval cookie_name )
' Returns cookie named cookie_name.
If Request.Cookies( "UserSettings") Is Nothing Then
return ""
else
cookie_value = Server.HtmlEncode(Request.Cookies( "UserSettings" )( cookie_name ))
return cookie_value
end if
end function