如果在A网站引用B网站的页面,获得B网站的Session,但是从A站点跳转到B站点后,B站点的Session失效了!
无法获得原来的Session。
经过同事的努力查找,找到相应的解决办法,详细内容如下:
http://support.microsoft.com/kb/323752/ (机器翻译的,极烂!)
http://support.microsoft.com/kb/323752/en-us
Session variables are lost if you use FRAMESET in Internet Explorer 6
function loadTOCNode(){}
Article ID |
: |
323752 |
Last Review |
: |
April 21, 2006 |
Revision |
: |
3.0 |
This article was previously published under Q323752
var sectionFilter = "type != 'notice' && type != 'securedata' && type != 'querywords'";
var tocArrow = "/library/images/support/kbgraphics/public/en-us/downarrow.gif";
var depthLimit = 10;
var depth3Limit = 10;
var depth4Limit = 5;
var depth5Limit = 3;
var tocEntryMinimum = 1;
<noscript></noscript>
SYMPTOMS
loadTOCNode(1, 'symptoms');
If you implement a FRAMESET whose FRAMEs point to other Web sites on the networks of your partners or inside your network, but you use different top-level domain names, you may notice in Internet Explorer 6 that any cookies you try to set in those FRAMEs appear to be lost. This is most frequently experienced as a loss of session state in an Active Server Pages (ASP) or ASP.NET Web application. You try to access a variable in the Session object that you expect to exist, and a blank string is returned instead.
You also see this problem in a FRAMEs context if your Web pages alternate between the use of Domain Name System (DNS) names and the use of Internet Protocol (IP) addresses.
CAUSE
loadTOCNode(1, 'cause');
Internet Explorer 6 introduced support for the Platform for Privacy Preferences (P3P) Project. The P3P standard notes that if a FRAMESET or a parent window references another site inside a FRAME or inside a child window, the child site is considered third party content. Internet Explorer, which uses the default privacy setting of Medium, silently rejects cookies sent from third party sites.
RESOLUTION
loadTOCNode(1, 'resolution');
You can add a P3P compact policy header to your child content, and you can declare that no malicious actions are performed with the data of the user. If Internet Explorer detects a satisfactory policy, then Internet Explorer permits the cookie to be set.
Visit the following MSDN Web site for a complete list of satisfactory and unsatisfactory policy codes:
Privacy in Internet Explorer 6
http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp (http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp)A simple compact policy that fulfills this criteria follows:
P3P: CP="CAO PSA OUR"
This code sample shows that your site provides you access to your own contact information (CAO), that any analyzed data is only "pseudo-analyzed", which means that the data is connected to your online persona and not to your physical identity (PSA), and that your data is not supplied to any outside agencies for those agencies to use (OUR).
You can set this header if you use the
Response.AddHeader method in an ASP page. In ASP.NET, you can use the
Response.AppendHeader method. You can use the IIS Management Snap-In (inetmgr) to add to a static file.
Follow these steps to add this header to a static file:
1. |
Click Start, click Run, and then type inetmgr. |
2. |
In the left navigation page, click the appropriate file or directory in your Web site to which you want to add the header, right-click the file, and then click Properties. |
3. |
Click the HTTP Headers tab. |
4. |
In the Custom HTTP Headers group box, click Add. |
5. |
Type P3P for the header name, and then for the compact policy string, type CP=..., where "..." is the appropriate code for your compact policy. |
Alternatively, Internet Explorer users can modify their privacy settings so that they are prompted to accept third party content. The following steps show how to modify the privacy settings:
1. |
Run Internet Explorer. |
2. |
Click Tools, and then click Internet Options. |
3. |
Click the Privacy tab, and then click Advanced. |
4. |
Click to select the Override automatic cookie handling check box. |
5. |
To allow ASP and ASP.NET session cookies to be set, click to select the Always allow session cookies check box. |
6. |
To receive a prompt for any type of third party cookie, click Prompt in the Third-party Cookies list. |
STATUS
loadTOCNode(1, 'status');
This behavior is by design.
MORE INFORMATION
loadTOCNode(1, 'moreinformation');
Steps to reproduce the behavior
loadTOCNode(2, 'moreinformation');
1. |
Create a file name TestFrameset.asp. |
2. |
Point one of the FRAMEs of the file to another computer on your network, by means of IP addresses:
<HTML>
<FRAMESET ROWS="100%,*">
<FRAME src="http://111.111.111.111/testFrame.asp"></FRAME>
<FRAME src="about:blank"></FRAME>
</FRAMESET>
</HTML>
|
3. |
On the remote computer, create TestFrame.asp like the following example:
<HTML>
<BODY>
<%
Response.write "Session var is " & Session("TestVar")
Session("TestVar") = "Hello, world!"
%>
<BODY>
<FORM METHOD="POST">
<INPUT type="submit" value="Print TestVar">
</FORM>
</BODY>
</HTML>
|
4. |
Move to TestFrameset.asp, and then click Form Submission. |
Notice after the submission that
Session("TestVar") entry prints as empty, although it should contain "Hello, world!".
REFERENCES
loadTOCNode(1, 'references');
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
283185 (http://support.microsoft.com/kb/283185/) How to manage cookies in Internet Explorer 6
290333 (http://support.microsoft.com/kb/290333/) Description of Platform for Privacy Preferences (P3P) project
293222 (http://support.microsoft.com/kb/293222/) The default privacy settings for Internet Explorer 6
具体解决办法为:
修改B站点的IIS设置,设置Header,添加“P3P: CP="CAO PSA OUR"”
分享到:
相关推荐
这里的`CP="CAOPSAOUR"`表示站点遵循的隐私原则,允许跨站点访问和数据收集,但不会将其用于个性化广告等目的。 4. **使用JavaScript重定向:** 当检测到Session丢失时,可以使用JavaScript的`window.location....
在ASP.NET开发过程中,经常会遇到一种情况:当对网站进行某些特定操作(如修改或删除站内目录)时,原本正常的Session会突然失效或丢失。这不仅影响用户体验,还可能导致一系列安全性和功能性的隐患。本文将详细分析...
- **问题**:设置过长的 Session 生存期可能导致服务器内存消耗过大。 #### 五、对服务器负担的比较 **1. Cookies** - **优势**:由于存储在客户端,不会增加服务器的负担。 - **适用性**:对于高并发访问的站点,...
- Cookie: 每个Cookie大小限制在4KB左右,且浏览器一般允许每个站点最多存储20个Cookie。 - Session: 由于存储在服务器,理论上存储量更大,受服务器内存限制。 4. **有效期** - Cookie: 可以设置为持久化或临时...
此外,如果开发者需要强制结束Session,还可以调用`invalidate()`方法来使Session失效。 总之,理解和掌握通过Request对象获取和管理Session的方法是Web开发者进行用户状态管理和维护会话安全的必备技能。在实际...
总结来说,Cookie和Session在.NET中用于跟踪用户状态,Cookie适合存储非敏感信息且可跨站点访问,而Session提供更安全的存储方式,但消耗服务器资源。根据实际需求选择合适的状态管理策略,以平衡安全性和性能。
- **Session 认证下的挑战**: 实现单点登录时,Session 需要在多台服务器间共享,这可能导致性能问题并增加复杂性。 - **JWT 的优势**: JWT 存储在客户端,可以在不同服务之间自由传递,不需要额外的服务器端同步...
3. **会话管理框架**:使用Spring Security等安全框架,它们提供了强大的会话管理功能,包括会话固定保护、会话超时检测和跨站点请求伪造(CSRF)防护等。 4. **分布式会话**:在大型应用中,可能需要将会话数据...
跨站点脚本攻击是一种常见的攻击方式,通过在受害者的浏览器中执行恶意脚本来实现。这通常发生在应用程序未能正确过滤用户提交的数据时。 **应对措施**:对用户提交的所有数据进行严格的输入验证,并确保对输出数据...
- **数量限制**:浏览器对每个站点的Cookie数量有限制,过多的Cookie会影响性能。 - **大小限制**:单个Cookie的大小不能超过4KB,所以不适合存储大量数据。 - **隐私考虑**:合理设置Cookie的生命周期,避免存储...
这种方法有效地解决了缓存失效问题,提高了用户体验。 #### 3. Session 服务器区 Session管理对于保持用户的登录状态和个性化设置至关重要。文中提到的Shared Nothing Architecture是一种典型的无共享架构,它确保...
- **默认session过期时间**:默认为30分钟,即如果没有新的请求在30分钟内发送到服务器,session将会失效。 - **计数器功能**:通过同一个session访问时计数器递增,不同的session访问则分别计数。 - **设置...
集群环境下的安全问题包括跨站点脚本攻击(XSS)、SQL注入等,需要确保每个节点都有相应的安全配置,例如使用HTTPS、防火墙规则等。 10. **最佳实践**: - 使用虚拟化技术,如Docker或Kubernetes,管理Tomcat集群,...
- **SameSite属性**:用于防止跨站点请求伪造(CSRF)攻击。 ### Cookie的编程实现 在编程中,可以根据不同的语言和框架设置和操作Cookie。例如,在Java中使用`javax.servlet.http.Cookie`类来操作Cookie,可以...
在跨站脚本漏洞,但是因为对后台的不了解,无法构造完美的ajax代码来利用,即使可以用js 取得后台的代码并回传分析,但是过程同样烦琐而且不隐蔽。这个时候,利用xss漏洞获得 Cookie或者Session劫持就很有效了,具体...
CSRF(Cross-Site Request Forgery,跨站请求伪造)是一种常见的网络安全威胁,它利用了用户的已登录状态和浏览器的行为特性,使得攻击者能够在用户不知情的情况下执行非授权的操作。了解CSRF攻击的产生原因对于构建...
在Web应用程序开发过程中,为了防止重复提交表单或CSRF(跨站请求伪造)等安全问题,Struts2框架提供了一种名为“令牌”的机制。该机制通过在用户会话中存储一个随机生成的唯一值,并在表单提交时验证该值是否有效来...
* 请求转发只能将请求转发给同一个 Web 应用中的组件,而 sendRedirect() 方法不仅可以重定向到当前应用程序中的其他资源,还可以重定向到其他站点的资源。 * 请求转发过程结束后,浏览器地址栏保持初始的 URL 地址...
1. 在使用和部署任何开源代码之前,必须进行全面的安全审查,避免潜在的注入攻击、跨站脚本攻击(XSS)等问题。 2. 确保系统及时更新,修补可能存在的安全漏洞。 3. 对敏感数据进行加密处理,保护用户隐私。 4. 设置...