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

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 閱讀(832) 評論(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   管理


<2010年1月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

常用鏈接

留言簿(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>
            久久久久成人精品免费播放动漫| 欧美日韩国产成人在线| 久久亚洲精品伦理| 欧美在线观看一二区| 欧美亚洲免费电影| 欧美一区二区精品久久911| 欧美中文字幕在线观看| 久久久噜噜噜| 欧美成人精品福利| 亚洲黄色成人网| 亚洲精品国产欧美| 一本色道久久精品| 欧美在线观看一区| 欧美顶级艳妇交换群宴| 国产精品久久久久av| 合欧美一区二区三区| 亚洲欧洲在线观看| 欧美在线不卡视频| 亚洲黑丝在线| 欧美中文字幕视频在线观看| 欧美激情偷拍| 一区二区三区自拍| 亚洲自拍另类| 亚洲片国产一区一级在线观看| 亚洲欧美日韩天堂| 欧美久久久久中文字幕| 国产性猛交xxxx免费看久久| 日韩视频免费观看高清在线视频| 久久精品水蜜桃av综合天堂| 欧美日韩国产三级| 久久不射中文字幕| 欧美片第一页| 欲色影视综合吧| 午夜欧美不卡精品aaaaa| 欧美国产第一页| 久久精品亚洲| 国产欧美日韩专区发布| 国产精品99久久久久久久久| 欧美成人精品一区| 欧美一区视频在线| 国产精品国产福利国产秒拍| 日韩午夜精品视频| 免费在线观看精品| 欧美一区二视频| 国产精品综合不卡av| 中文有码久久| 亚洲精品美女| 欧美日韩999| 亚洲美女在线国产| 亚洲第一偷拍| 久久综合九色| 亚洲第一视频网站| 欧美福利小视频| 蜜桃久久精品乱码一区二区| 亚洲国产日韩美| 卡一卡二国产精品| 久久久久久久综合| 一区在线播放| 嫩草伊人久久精品少妇av杨幂| 久久精品噜噜噜成人av农村| 国内精品写真在线观看| 久久精品成人欧美大片古装| 午夜精品一区二区三区在线| 国产欧美一区二区精品性色| 久久高清一区| 久久婷婷色综合| 亚洲国产成人一区| 亚洲高清不卡在线观看| 欧美成人午夜剧场免费观看| 亚洲乱码久久| 中日韩美女免费视频网址在线观看| 欧美日韩美女一区二区| 亚洲欧美国产日韩中文字幕| 亚洲欧美日韩精品在线| 影音先锋日韩资源| 亚洲高清视频在线观看| 欧美日韩你懂的| 欧美在线视频在线播放完整版免费观看| 亚洲女女女同性video| 国产曰批免费观看久久久| 免费观看亚洲视频大全| 欧美成人免费在线| 亚洲一区成人| 欧美在线视频导航| 亚洲国内精品在线| 这里只有精品视频在线| 国产一区二区三区视频在线观看 | 国产偷久久久精品专区| 亚洲激情网站| 一区二区三区久久久| 这里只有视频精品| 韩国av一区二区三区四区| 亚洲激情网站免费观看| 国产乱码精品一区二区三区av| 久热精品视频在线免费观看 | 国产精品日韩一区二区| 久久夜色精品| 欧美视频日韩视频| 久久天天躁狠狠躁夜夜av| 欧美日韩成人一区二区| 久久中文字幕一区二区三区| 欧美日韩中文字幕| 欧美国产精品专区| 国产精自产拍久久久久久| 欧美r片在线| 国产乱人伦精品一区二区| 亚洲国产精品成人va在线观看| 国产精品国内视频| 亚洲丶国产丶欧美一区二区三区 | 欧美激情中文不卡| 久久久综合激的五月天| 欧美色视频在线| 欧美二区不卡| 一区二区三区在线不卡| 亚洲在线视频一区| 在线一区亚洲| 欧美精品久久久久久久久老牛影院| 久久精品国产第一区二区三区| 欧美日本在线视频| 欧美激情在线播放| 激情六月综合| 久久精彩免费视频| 久久久精品免费视频| 国产免费观看久久| 在线亚洲高清视频| 一区二区三区欧美| 欧美精品激情在线观看| 亚洲国产日韩欧美| 最新亚洲激情| 欧美成人在线免费观看| 女仆av观看一区| 激情久久一区| 久久影院午夜论| 免费久久精品视频| 在线观看日韩专区| 久久久999精品免费| 麻豆91精品| 亚洲国产欧美不卡在线观看| 老色批av在线精品| 亚洲高清成人| 一区二区福利| 国产精品电影网站| 国产精品99久久久久久白浆小说 | 欧美亚洲综合在线| 久久精品亚洲热| 一区二区亚洲精品| 免费久久99精品国产| 亚洲激情电影在线| 中日韩视频在线观看| 国产精品女人网站| 欧美在线看片a免费观看| 蜜臀a∨国产成人精品| 亚洲风情亚aⅴ在线发布| 亚洲精品日韩一| 欧美视频中文字幕在线| 亚洲女女做受ⅹxx高潮| 狂野欧美激情性xxxx| 亚洲人体1000| 欧美日韩午夜| 欧美在线黄色| 最新国产成人av网站网址麻豆| 亚洲香蕉在线观看| 国产一区二区在线观看免费| 美国三级日本三级久久99| 日韩午夜免费| 久久不射网站| 亚洲国产欧美不卡在线观看| 欧美日韩综合在线免费观看| 欧美一级在线播放| 亚洲国产欧美在线人成| 午夜精品www| 亚洲国产高潮在线观看| 国产精品久久久久一区二区| 久久久国产视频91| 亚洲免费精品| 麻豆精品在线视频| 亚洲一区一卡| 亚洲第一综合天堂另类专| 欧美深夜影院| 久久综合精品国产一区二区三区| 一本久久青青| 欧美福利视频网站| 久久精品国产综合| 亚洲一区二区三区色| 亚洲欧洲视频| 一区二区在线视频播放| 国产精品久久久久久久第一福利| 快she精品国产999| 欧美一级午夜免费电影| 国产精品99久久久久久有的能看| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久久欧美精品| 宅男精品视频| 欧美激情精品久久久| 久久天天躁狠狠躁夜夜av| 亚洲自拍偷拍色片视频| 日韩一级大片| 亚洲精选视频免费看| 亚洲激情网站| 亚洲黄色三级|