我有一个问题,我下载了一个第三方论坛,然后自己做了一个主站。论坛放在根目录下bbs文件夹里面,主站直接放在根目录下。论坛用户登陆后,会写入cookie,我想在主站这里得到这个登陆用户信息。但是我发现主站这里无法得到,原因是论坛的cookie是有路径的。比如我的域名是www.123.com,那么论坛的cookie的路径是www.123.com/bbs/。我找到源码,把里面写cookie的path的语句注释掉了,还是会有路径。这样该如何操作呢?谢谢

解决方案 »

  1.   

    仅仅这样还是不行。我分别用两个域名去访问它:
    www.123.com/bbs/

    bbs.123.com
    发现,在本机的cookie文件夹里面还是保存了两个文件,而且打开cookie文件,可以看到里面写的。
    前者路径是
    www.123.com/
    后者路径是
    bbs.123.com/
      

  2.   

    能否直接写死,不让cookie自动变化。我就想直接写死为www.123.com
      

  3.   

    domain=domainname; Setting the domain of the cookie allows pages on a domain made up of more than one server to share cookie information.  
    path=path; Setting a path for the cookie allows the current document to share cookie information with other pages within the same domain—that is, if the path is set to /thispathname, all pages in /thispathname and all pages in subfolders of /thispathname can access the same cookie information.  这两个都写死他...
      

  4.   

    楼上的朋友,麻烦说详细点吧?困扰我很久了
    我发现如果绑定两个域名到同一个文件夹,比如bbs.123.com和forum.123.com都绑定到根目录下bbs文件
    然后分别用bbs.123.com和forum.123.com登录网站,cookie文件会生成2个
      

  5.   

    论坛源码如下Sub setCookie(strCookieName, strCookieKey, strValue, blnStore)
         'Write Cookie
    Response.Cookies(strCookiePrefix & strCookieName)(strCookieKey) = strValue
    Response.Cookies(strCookiePrefix & strCookieName).Path = strCookiePath
    'If blnStore Then
    Response.Cookies(strCookiePrefix & strCookieName).Expires = DateAdd("yyyy", 1, Now())
    'End If
    End Sub用www.123.com/bbs/访问的时候cookie文件如下'文件名:杨云召@www.cgunited[1].txt
    '内容如下,节选部分
    WWF9sLID
    UID=yangyunzhao2EA2BZEZ5Z
    www.cgunited.com/bbs/
    1024
    4266696704
    30084751
    2250715504
    30011326
    *当用bbs.123.com访问的时候文件如下'文件名:杨云召@bbs.cgunited[1].txt
    '内容如下,节选部分
    WWF9sLID
    UID=yangyunzhao2EA2BZEZ5Z
    bbs.cgunited.com/bbs/
    1024
    3191729408
    30084752
    1173248208
    30011327
    *
      

  6.   

    就是
    domain="cgunited.com"
    path="/"