青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 297,  comments - 15,  trackbacks - 0
Opening the same web page in multiple browser tabs or windows can cause some serious problems if that page relies on cookies or session state. If you're lucky, the problem will be obvious to the user but it's quite possible that they'll be completely unaware of it until after they've corrupted some data.
The Problem

Imagine the user of a web application, viewing details of Object1. The user wants to compare Object1 with Object2 so opens the details of Object2 in a second window or tab. If the application is storing the "current object id" in session state or a cookie then this value will now correspond to Object2. The user then decides to modify Object1's details, so amends them on the page and saves the changes.

If the application is really badly coded then the save operation could update the record corresponding to the current object id (Object2) with the new details for Object1. Even if it updates the right record, the current id in session state is still wrong - if this id is used to select the data for the next page that the user visits then they will end up with both tabs/windows pointing at Object2.

Processes

The problem stems from the fact that multiple tabs and windows can be running in the same process.

Firefox uses the same process for multiple tabs and, by default, the same process for all windows, whether they are launched from Windows or from each other (Ctrl-N style).

IE6 managed it's own processes so you could never be entirely certain about when further processes would be created unless you forced the situation using the -new command line switch. The most common situation I've found is that Ctrl-N creates a window using the existing process, Javascript calls (e.g. window.open, window.show...) use the existing process, but launching IE from Windows creates a new process.

IE7 has abandoned the -new switch, and seems to use a new process for each new window launched from Windows. All tabs within a window, however, run under one process, and spawning windows with Ctrl-N or Javascript commands seems to always re-use the existing process as well.
Cookies and Session State

Sharing a process isn't itself a bad thing. Time and resources can be saved by this approach, but unfortunately a browser's cookies are tied to it's process. If a page is displayed in two tabs or windows running in the same process, then the two instances of the page will share their cookies.

There are two types of cookie. Persistent cookies are saved to disk and kept until their expiry date. Persistent cookies will always be shared between multiple instances of the same page, regardless of whether the pages are running in the same browser process. If the page creates a persistent cookie called "ObjectID" then this will be stored in a file on disk and will be accessible to any other instance of that same page (unless you use a different browser application - IE and Firefox do not share cookies).

Session cookies, on the other hand, are kept in memory and are only available until the browser process ends. If two instances of a web application run in two separate processes then there will be two separate session cookies, but if the two instances are in the same process, then they will share the session cookie.

Furthermore, if the web application is relying on a session cookie to store a session id (the default setup for an ASP.NET web application is to store the ASP.NET_SessionId in a session cookie) then anything in session state will be shared between the two pages: if one of them updates session state then the other will be affected.

Options

What this means for a developer is that it is quite possible that your application will have to cope with multiple copies of the same page running in the same process, sharing cookies. Ideally you should be able to have each page running independently of the others, regardless of them sharing a process.

Normally you can work around the problem by using viewstate. Small objects can be stored directly in viewstate but you shouldn't be sending anything too big down the line to the browser. If your object is more than a simple integer or short string then it will probably be better to generate a GUID and store that in viewstate, using the GUID to access a part of sessionstate which can be kept unique for that instance of the page, regardless of the process-sharing.

In the example we began with, the current object id could easily be stored in viewstate. If there was an object that needed to be persisted for some reason then it would probably be better off in session state, so the second technique would be better.

There are times, however, when viewstate doesn't work. In some situations (for example, setting up dynamically generated controls) the current object id may be required in Page_Init, when viewstate is not available. This was actually the situation which lead to us developing an HTA-based intranet (each instance of an HTA has it's own process, so cookies and sessions are never shared), but HTA is not an option for a normal website.

Probably the best solution, if you're using ASP.NET, is cookieless sessions. In this situation the ASP.NET session id is part of the URL, and is not shared between tabs or windows. This solution works well in the Page_Init situation, but leads to some very unwieldy URLs and has other drawbacks connected to security and absolute linking. It is also an application (or machine) setting, so cannot be used as a last resort only for those few pages that need Page_Init.

Conclusion

In general, viewstate is the perfect solution to the problem. Each instance of a page can keep track of its own state, with no interference from other instances.

When state information is required in Page_Init things get a little more complicated and cookieless sessions are definitely worth considering.



Test Code

A simple page incrementing a counter in session state can be used to demonstrate the problem. Launching new windows with CTRL-N in either browser will default to using the existing process, as will all tabs.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim x As Integer

If IsNothing(Session("test")) Then
x = 1234
Else
x = CInt(Session("test")) + 1
End If

Session("test") = x

Label1.Text = CInt(Session("test"))

End Sub

forwarded by as follows:
http://www.cloudward.net/techLife/article.asp?id=1758
posted on 2009-04-03 16:58 chatler 閱讀(840) 評論(2)  編輯 收藏 引用 所屬分類: browser

FeedBack:
# re: Browsers, processes, cookies and session state
2009-04-05 15:57 | domolo

文章說的很清楚,多謝

我有一個問題:
如何為每個ie instance ie實例的 Persistent cookies cookie 指定不同的存儲目錄?  回復  更多評論
  
# re: Browsers, processes, cookies and session state
2009-04-07 00:33 | chatler
每個IE Instance該是不同的進程吧,可以獲取進程ID,在每個instance里建一個名稱包含進程id的目錄名,就可以分目錄存儲了吧。  回復  更多評論
  

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用鏈接

留言簿(10)

隨筆分類(307)

隨筆檔案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

  • cloudward
  • 感覺這個博客還是不錯,雖然做的東西和我不大相關,覺得看看還是有好處的

network

OSS

  • Google Android
  • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
  • os161 file list

overall

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美一区综合| 久久精品人人做人人综合| 欧美国产日韩视频| 亚洲片区在线| 亚洲色无码播放| 国产精品久久午夜夜伦鲁鲁| 亚洲欧美一区二区激情| 久久一区中文字幕| 91久久国产综合久久| 欧美日产一区二区三区在线观看| 亚洲少妇自拍| 久久婷婷久久| 99精品免费| 国产自产v一区二区三区c| 美女视频网站黄色亚洲| av不卡在线观看| 久久精品人人做人人综合| 亚洲人成精品久久久久| 欧美午夜在线观看| 久久久久国产精品麻豆ai换脸| 91久久精品国产91久久| 欧美一区三区三区高中清蜜桃| 一区二区三区在线免费观看| 欧美日韩免费一区二区三区视频| 亚洲永久免费| 亚洲国产aⅴ天堂久久| 午夜视频一区二区| 亚洲观看高清完整版在线观看| 欧美特黄一区| 免费亚洲电影| 羞羞色国产精品| 亚洲乱码国产乱码精品精天堂| 久久久久久色| 在线视频日韩精品| 在线成人免费视频| 国产精品日韩欧美一区二区三区 | 午夜欧美不卡精品aaaaa| 有坂深雪在线一区| 国产精品素人视频| 欧美国产亚洲另类动漫| 久久大香伊蕉在人线观看热2| 亚洲精品激情| 欧美成人高清| 久久五月激情| 久久精品噜噜噜成人av农村| 亚洲视频二区| 99v久久综合狠狠综合久久| 激情丁香综合| 国内精品久久久久久影视8| 欧美三级在线播放| 欧美激情视频一区二区三区在线播放 | 美女日韩欧美| 久久久久国内| 欧美一区二区私人影院日本| 99国内精品久久| 亚洲啪啪91| 亚洲激情视频在线| 亚洲成色www8888| 国产在线观看一区| 国产日韩亚洲欧美综合| 国产精品久久毛片a| 欧美日韩国语| 欧美日韩成人在线观看| 欧美成年人视频| 欧美1区2区3区| 狂野欧美激情性xxxx欧美| 久久久夜夜夜| 久久九九热免费视频| 欧美在线观看天堂一区二区三区| 亚洲综合成人婷婷小说| 亚洲男人的天堂在线aⅴ视频| 亚洲天天影视| 午夜精品久久99蜜桃的功能介绍| 亚洲四色影视在线观看| 亚洲一区在线看| 亚洲综合日韩在线| 午夜精品久久久久久久99水蜜桃 | 亚洲欧美另类国产| 亚洲欧美日韩高清| 午夜精品久久久久| 欧美一区二区三区在线| 久久久久一本一区二区青青蜜月| 久久久精品动漫| 麻豆精品传媒视频| 欧美精品色网| 国产精品久久一区主播| 国产亚洲精品bt天堂精选| 国产在线精品一区二区中文| 伊人久久综合97精品| 亚洲国产视频一区| 一本色道久久综合亚洲精品婷婷| 中日韩视频在线观看| 亚洲欧洲99久久| 久久久久久黄| 亚洲福利视频三区| 一区二区三区四区精品| 午夜免费日韩视频| 久久字幕精品一区| 欧美色欧美亚洲另类七区| 国产日产亚洲精品系列| 亚洲第一页中文字幕| 亚洲图片在区色| 久久久久久久999精品视频| 欧美高清在线视频| 一区二区三欧美| 久久久免费精品| 欧美日韩性视频在线| 国产亚洲精品资源在线26u| 亚洲国产精品成人综合| 亚洲欧美国内爽妇网| 免费观看国产成人| 中文国产成人精品久久一| 久久av一区二区三区| 欧美日韩高清不卡| 国产在线高清精品| 中日韩美女免费视频网站在线观看| 久久激五月天综合精品| 亚洲欧洲日产国产综合网| 午夜精品久久久久99热蜜桃导演| 欧美国产高清| 国内成人精品2018免费看 | 欧美日韩dvd在线观看| 国产午夜精品一区理论片飘花 | 亚洲网站在线播放| 久久在线视频| 这里只有精品丝袜| 欧美96在线丨欧| 国产一区二区三区久久精品| 亚洲毛片一区二区| 麻豆av一区二区三区久久| 99热免费精品| 牛牛国产精品| 韩日欧美一区| 欧美一区二区日韩| 亚洲精品一区久久久久久| 久久久亚洲成人| 国产视频一区在线观看一区免费| 99天天综合性| 亚洲福利电影| 噜噜噜在线观看免费视频日韩| 国产色爱av资源综合区| 亚洲欧美区自拍先锋| 亚洲精品久久久久久一区二区| 久久久免费精品| 国产综合色精品一区二区三区| 午夜亚洲激情| 亚洲视频1区| 欧美视频中文字幕| 一区二区精品在线| 亚洲三级毛片| 欧美久久视频| 99精品热6080yy久久| 最新国产成人av网站网址麻豆| 久热国产精品| 亚洲日本va午夜在线电影| 欧美国产欧美亚洲国产日韩mv天天看完整| 午夜伦理片一区| 国产综合精品| 久久久久久精| 久久久亚洲影院你懂的| 一区二区三区在线视频免费观看| 久久综合给合久久狠狠色 | 一本色道久久加勒比88综合| 欧美国产先锋| 欧美激情精品久久久久| 亚洲精选中文字幕| 91久久极品少妇xxxxⅹ软件| 欧美福利视频| 一区二区欧美在线观看| 日韩亚洲欧美一区二区三区| 欧美午夜激情视频| 午夜精品999| 午夜精品999| 在线 亚洲欧美在线综合一区| 牛牛国产精品| 欧美日韩成人一区二区| 亚洲女人小视频在线观看| 亚洲一区二区三区高清| 国产亚洲欧美一区二区| 免费久久99精品国产自在现线| 欧美成人tv| 亚洲一二三区在线观看| 午夜伦理片一区| 亚洲国产精品一区| 99re在线精品| 国产视频亚洲精品| 欧美国产专区| 国产精品免费观看视频| 久久夜色精品国产亚洲aⅴ| 欧美超级免费视 在线| 亚洲一区二区三| 欧美在线视频观看| 日韩视频一区二区在线观看 | 久久国产精品久久久久久| 伊人成人在线视频| 亚洲精品一区二区三区在线观看 | 午夜精品久久久久久久久久久久| 国内精品一区二区三区| 91久久久久久久久久久久久| 国产精品视频观看|