Frame中关于Session丢失的解决方法!

IFrame中Session丢失的解决办法 立即下载

转自:http://www.cnblogs.com/tintown/archive/2007/06/04/770678.html

在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session的。因此,网上可以找到很多相关的文章,如果网站可以采用设置Web.Config中的配置:<sessionState
mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="40"
/>
把cookieless="false"改成"true"就可以了。但也同样有个小问题,就是如果页面中采用Javascript的window.location.href=''这样的方式来重定向的话,系统会认为这是另一个新的请求,产生一个新的SessionId,导致原Session同样的丢失。所以对于重定向,还是使用Response.Redirect()为好。

除了Ifrmae有丢Session问题外,frameset也有同样的问题。Frameset的问题更不移定,是有时会丢,有时不会丢,这更认人头痛,在网上找到了一个方法,在页面page_onload里添加一语句:
Response.AddHeader("P3P","CP=CAO PSA OUR");
FrameSet中的Session丢失问题就解决了。至于里面具体的原因 也没时间去搞懂了。 

-----------------------------------------------------------------------------------------------------------------------------------------------

在实际操作中,以上设置将导致对方post过来的数据我方接收不到的问题,正确的解决方法应该是:

http://www.cnblogs.com/suxvsheng/archive/2007/08/17/860157.html

偶然中发现一个IE浏览器的问题:
        站点aa.com的页面a.aspx中存在一个iframe,iframe的src为站点bb.com的b.aspx。b.aspx设置了一个COOKIE(不管临时保存还是长期保存),然后刷新aa.com/a.aspx,bb.com/b.aspx也会被刷新,这时候会发现第二次向bb.com/b.aspx的请求里面并没有带入第一次设置的COOKIE。
     更确切地说:IE浏览器丢掉了框架中不同域的COOKIE。

    查看浏览器的隐私选项,默认是“中”。现在把隐私的等级修改成“低”,再次做上面的测试,然后发现框架中的COOKIE可以被带入了。
   从这个现象来看,应该是IE出于安全考虑而做了限制。但是!!!处于不同的两个域的的页面,应该被看成打开了两个互不相关的浏览器窗口,大家各自设置自己的COOKIE,各自带入到下次请求中,只要互不影响,不应该受到限制。
      恩,那么,为什么要限制呢?看来还是微软的程序员对自己浏览器的安全没什么信心,担心同一浏览器窗口不同域的情况下,黑客仍可能获取另一域的COOKIE,所以干脆把其中一个域的COOKIE干掉!!!人家FireFox为什么就没这种限制?

===========================================================================

问题根源:

IE6/IE7支持的P3P(Platform for Privacy Preferences Project (P3P) specification)协议默认阻止第三方无隐私安全声明的cookie,Firefox目前还不支持P3P安全特性,firefox中自然也不存在此问题了。Mircosoft对此的具体描述可以参见 Privacy in Internet Explorer 6

解决方法:

很简单,在要嵌入的内容中(iframe指向的站点)输出P3P的主机头声明,步骤如下(Session variables are lost if you use FRAMESET in Internet Explorer 6):

1.打开IIS管理器 inetmgr
2.选择被嵌入iframe源站点或者目录,右键点击打开属性框
3.切换到HTTP头
4.添加
5.自定义HTTP头名: P3P
6.自定义HTTP头值: CP="CAO PSA OUR"
7.关闭属性框退出,即刻生效
至于上面CAO PSA OUR的具体意思,还是请参考前面的文章:Privacy in Internet Explorer 6

至此,iframe框架下session丢失的问题才彻底解决。

iframe跨域访问时session丢失 NULL 博文链接:https://thoreau.iteye.com/blog/745100 立即下载

相关推荐

matinal:S4 HANA 详解ACDOCA与BSEG的区别都在这了

当你在Coding Block中添加自定义字段的时候

matinal 當冬夜漸暖 。公众号:matinal 4567

谷歌浏览器SameSite=lax导致嵌入Iframe 地址无法设置cookie问题

问题描述: 页面中通过Iframe嵌入了另外一个网页,但是嵌入的网页无法设置cookie,导致无法访问。仔细检查,在浏览Set-cookie的响应头出发现提示:This Set-Cookie didn't specify a "SameSite" attribute and was defaulted to "SameSite=lax", and was blocked because it came from a cross-site response which was not the r...

ysyysjbama的博客 1万+

数模笔记_多变量最优化计算之牛顿法

Date: 2_22 Name: Guo Yehao Theme: Calculation in Optimality with multiple variables Reference: 数学建模方法与分析(华章) 在上一节中,我们讨论多变量最优化计算中的随机搜索算法,它的精度并不是众多算法中最高的。在精度问题上,有的时候问题本身就带有明显的误差性,以至于我们不能将其忽略,比如上一节消防站部署的问题,我们在区域划分时就有了误差,因此我们并不需要对结果要求很高的精确度,所以用一些比较粗略的算法就可以.

weixin_45358177的博客 2415

[转] IFrame中Session丢失的解决办法……

2007-09-21 14:272301人阅读评论(3)收藏举报 在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session的。因此,网上可以找到很多相关的文章,如果网站可以采用设置Web.Config中的配置:<sessionStatemode="StateServer"stateConnectio...

weixin_30586085的博客 323

OV5640调试大坑,关于binning、RES分辨率与EV曝光

OV5640在使用binning模式时,必须考虑使用场景,分辨率下降叠加动态范围压缩,会使目标对象细节在高光环境下大量丢失,2x2的binning模式,分辨率会远低于感光面积的1/4。

chongyun_的专栏 1824

lgv20刷twrp_LG港版v20 root

这是LG港版v20 root,整理了一下有关LG港版v20的官方固件包了,有没有需要的呢,这里把固件包整理一下也是方便大家以后好下载了,因此有一些机友还是不知道在哪里下载官方的rom包,在这里说的固件rom包也就是原版的系统包了,大家可以放心的使用,这些系统包也都是支持线刷的,大家下载下来解压出来根据里面的相关教程来操作就可以了,很简单的,如果你也需要的话就一起来看看吧。软件提示注意!! 此过程会...

weixin_33212263的博客 5387

iframe调用action接口加载jsp时,session丢失问题

iframe调用action接口加载jsp时,session丢失问题问题来源分析问题解决问题插入链接与图片如何插入一段漂亮的代码片新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 问题来源 最近开发的ssh框架项目,要进行上线,因为项目中设计了登录权限,需要用到session来存储信息,在进行接口联调的时候才得知运营人员是使用iframe进行接口调用的,联调时发现接口可以直接在浏览器地址栏访问并加载出界面数据,在使用iframe调用时数据加载不出来 分析问题 在后台经过分析

weixin_51172484的博客 2439

Python 打包与发布陷阱:如何用 setuptools 和 PyInstaller 生成跨平台可执行文件?

使用。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1206

iframe,Frame中Session丢失的解决方法

在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session的。因此,网上可以找到很多相关的文章,如果网站可以采用设置Web.Config中的配置:mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="dat

happydaisy1985的专栏 9335

QGIS基于快鸟(QuickBird)影像统计小麦种植面积

​01数据情况 本次选用某地4月份快鸟(QuickBird)影像为例,使用QGIS演示提取小麦播种情况,并按照200米*200米分区计算种植面积的过程。 注:本文对应的操作视频作为今天第二篇推送同时发布,习惯看视频的朋友可以点击观看。 附数据压缩包: 链接:https://pan.baidu.com/s/1JVUS8uAOR61RxC1n9Or9_w 提取码:qgis 含快鸟影像QB_subset.tif和200*200米分区矢量图层200Mgrid.shp。 ...

QGISClass的博客 1979

Avalonia 超级详细学习指南

什么是 Avalonia?Avalonia 是一个开源的、跨平台的 GUI 框架,允许开发者使用 XAML 和 C# 构建现代化、高性能的桌面应用程序。与其他框架相比,Avalonia 具有强大的跨平台能力和灵活的界面设计。} }()Avalonia 的特点和优势跨平台性:Avalonia 可以在 Windows、Linux、macOS 等多个平台上运行,开发者可以编写一套代码,然后在不同的操作系统上运行相同的应用程序。

仰望星空的博客 1万+

iframe,Frame中关于Session丢失的解决方法

google_ad_client = "pub-2048279401139630";google_ad_slot = "8856771542";google_ad_width = 728;google_ad_height = 90;document.write("");在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Ses

aspgreener的专栏 1930

Xilinx FPGA平台GTX简易使用教程(四)GTX IP核配置教程

干货来了,GTX IP核配置,搬砖全靠它~~

数字IC/FPGA杂货铺,找一找,或许有你想要的~ 1万+

Frame中Session丢失的解决方法

开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session的。因此,网上可以找到很多相关的文章,如果网站可以采用设置Web.Config中的配置:mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data

eveJlie的专栏 1163

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Frame中关于Session和Cookie丢失的解决方法

在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session和Cookie的。因此,网上可以找到很多相关的文章,如果网站可以采用设置Web.Config中的配置:mode="StateServer"stateConnectionString="tcpip=127.0.0.1:42424"sqlConnectionString

646

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Frameset导致Cookies和Session丢失的原因及解决办法

1.Frameset导致Cookies和Session丢失的原因及解决办法  使用框架(Frameset)调用不同域名下的页面,会出现此域下页面的Cookies和Session丢失的现象。   原因:基于IE6.0对W3C 关于cookie的P3P协议的支持,使用框架调用不同域下的页面,默认情况下IE会自动禁用此域下的Cookies,因此会出现Cookies和Session丢失的现象

PI_ZT的专栏 1417

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

关于在Frame中Session丢失的一种解释?

大家好!今天我在做一个Frame中,发现Session传不到右边的页面上去,怎么搞都是null,没有办法只好用了页面传值的办法,在后台注册此链接的NavigateUrl="/BSDFJ.aspx?id="+Session["UID"],问题是解决了,但为什么呢???? 看到一位大侠的观点,我觉得是有道理的,我就是这个问题:两个页面分别属于不同的虚拟目录,就是说Session是基于虚

网际浪子专栏(曾用名littlehb) 2084

使用frame框架session都是解决方案

问题:当frame框架下引用了另外一个站点的网页的话,session会存在丢失的情况。解决方案是,加入如下代码:response.addHeader("P3P", "CP=CAO PSA OUR")

Java, go's 1702

解决iframe,frame和框架丢失或获取不到session,cookies问题

解决iframe,frame和框架丢失或获取不到session,cookies问题 引用地址: Response.clear() Response.CacheControl = "no-cache" Response.Expires=0 Response.AddHeader "P3P", "CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR

我叫阿东亮 1万+
上一篇: DataGrid行的双击时弹出对话框和单击时行变色
下一篇: ASP.NET中获取URL的方法
wangrumeng
博客等级 码龄21年 33粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值