我有一个问题,我下载了一个第三方论坛,然后自己做了一个主站。论坛放在根目录下bbs文件夹里面,主站直接放在根目录下。论坛用户登陆后,会写入cookie,我想在主站这里得到这个登陆用户信息。但是我发现主站这里无法得到,原因是论坛的cookie是有路径的。比如我的域名是www.123.com,那么论坛的cookie的路径是www.123.com/bbs/。我找到源码,把里面写cookie的path的语句注释掉了,还是会有路径。这样该如何操作呢?谢谢
调试欢乐多
www.123.com/bbs/
和
bbs.123.com
发现,在本机的cookie文件夹里面还是保存了两个文件,而且打开cookie文件,可以看到里面写的。
前者路径是
www.123.com/
后者路径是
bbs.123.com/
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. 这两个都写死他...
我发现如果绑定两个域名到同一个文件夹,比如bbs.123.com和forum.123.com都绑定到根目录下bbs文件
然后分别用bbs.123.com和forum.123.com登录网站,cookie文件会生成2个
'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
*
domain="cgunited.com"
path="/"