-4

我在 VisualBasic 2010 上编写了一个 Web 应用程序,并且 cookie 在除 Internet Explorer 8 之外的所有浏览器中都存在。

下面的答案解决了这个问题。

4

1 回答 1

0

我通过重写我的 cookie 读写方法解决了这个问题。(使用 VisualBasic2010 开发并在 Windows Server 2008 上运行的 Web 应用程序)

sub update_cookie_string( cookie_string, cookie_subkey  )

    dim cookie_object as HttpCookie     
    if request.cookies( PROGRAM_COOKIE_NAME ) is nothing then   ' PROGRAM_COOKIE_NAME not at browser?
        cookie_object = new httpcookie( PROGRAM_COOKIE_NAME )           ' init cookie object as cookie named: PROGRAM_COOKIE_NAME
    else
        cookie_object = request.cookies( PROGRAM_COOKIE_NAME )          ' Read cookie named PROGRAM_COOKIE_NAME from page from browser
    End If

    cookie_object.Values( cookie_subkey ) = cookie_string       ' Update cookie_subkey with new value cookie_string
    cookie_object.Expires = DateTime.Now.AddDays(365)           ' set expiration for a long time
    response.Cookies.add( cookie_object )                   ' Send it back to browser for storage there.
end sub



' Retrieve stored cookie_subkey.
function get_cookie_string( byval cookie_subkey  ) 
    dim cookie_object as HttpCookie     
    if  request.cookies( PROGRAM_COOKIE_NAME ) is nothing then  ' PROGRAM_COOKIE_NAME not at browser?
        get_cookie_string = ""
    else
        get_cookie_string = Request.Cookies( PROGRAM_COOKIE_NAME )( cookie_subkey )  ' Return string value of cookie_subkey 
    End If
于 2012-08-03T14:42:34.503 回答