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

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   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用鏈接

留言簿(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>
            亚洲大胆视频| 久久久久www| 久久精品人人做人人爽电影蜜月| 国产午夜精品理论片a级大结局| 国产精品嫩草99av在线| 久久夜色精品亚洲噜噜国产mv| 久久精彩免费视频| 久久婷婷国产综合精品青草| 老司机一区二区三区| 欧美成人免费va影院高清| 亚洲成人自拍视频| 亚洲黑丝在线| 亚洲一区二区在线视频| 久久精品国产视频| 欧美精品一区二| 国产精品久久久久久超碰| 国产一区白浆| 亚洲美洲欧洲综合国产一区| 亚洲欧美日韩天堂| 麻豆久久精品| 亚洲免费高清视频| 欧美在线啊v| 欧美精品在线播放| 国产视频在线一区二区 | 欧美另类在线播放| 国产精品久久久久免费a∨| 在线色欧美三级视频| 亚洲一区久久久| 欧美激情一区| 久久久噜噜噜久久久| 国产精品久久二区二区| 亚洲国产毛片完整版| 欧美一区二区精品在线| 亚洲级视频在线观看免费1级| 久久国产成人| 国产精品大片| 一区二区激情视频| 欧美大片一区二区| 久久激情五月激情| 国产精自产拍久久久久久| aa级大片欧美三级| 欧美成人亚洲成人日韩成人| 久久se精品一区二区| 国产精品久久网| 一区二区日韩伦理片| 亚洲国产精品成人综合色在线婷婷| 欧美一区深夜视频| 国产日韩欧美日韩| 欧美一区91| 亚洲在线不卡| 羞羞答答国产精品www一本| 日韩午夜在线观看视频| 久久久天天操| 欧美一区久久| 国产一区二区三区无遮挡| 午夜精品视频一区| 亚洲五月六月| 国产精品拍天天在线| 香蕉成人久久| 亚洲欧美国产日韩天堂区| 国产精品二区影院| 亚洲男同1069视频| 亚洲免费中文字幕| 国产无遮挡一区二区三区毛片日本| 性欧美videos另类喷潮| 亚洲欧美日韩国产综合| 国产一区二区三区四区五区美女| 久久精品国产一区二区电影| 欧美中文字幕视频在线观看| 精品动漫3d一区二区三区免费版 | 久久一区精品| 亚洲高清视频一区| 亚洲国产精品久久久久久女王| 欧美xart系列高清| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美午夜a级限制福利片| 亚洲综合第一页| 欧美亚洲综合网| 在线电影院国产精品| 欧美风情在线观看| 欧美久久综合| 亚洲欧美另类综合偷拍| 午夜精品久久| 亚洲精美视频| 国产精品99久久久久久久女警 | 欧美一区成人| 久久久久国色av免费观看性色| 亚洲精品一区二区在线观看| 一本色道久久综合狠狠躁篇的优点| 国产精品夜夜嗨| 欧美激情一区二区三区在线 | 一区二区三区高清不卡| 午夜精品免费| 亚洲精品免费在线| 午夜精品福利在线| 亚洲理伦在线| 欧美亚洲尤物久久| 99re66热这里只有精品4| 午夜精品福利视频| 久久一本综合频道| 欧美精品在线一区| 久久国产精彩视频| 欧美成人综合一区| 久久激情视频免费观看| 欧美精品久久久久久久久久| 欧美影院在线| 欧美精品在线观看播放| 久久久久se| 欧美视频亚洲视频| 欧美高清视频一区二区三区在线观看 | 亚洲福利在线看| 国产一区二区三区久久久| 亚洲精品资源美女情侣酒店| 亚洲第一精品在线| 欧美一级视频免费在线观看| 亚洲视频在线看| 欧美高清日韩| 浪潮色综合久久天堂| 国产美女一区二区| 一区二区三区四区五区精品视频| 亚洲黄页一区| 美女91精品| 久久五月天婷婷| 国产一区二区三区久久久| 亚洲一区二区网站| 亚洲一区二区三区免费在线观看| 欧美成人精品h版在线观看| 久久视频一区| 韩国成人理伦片免费播放| 亚洲视频一区二区在线观看 | 国产老女人精品毛片久久| 99在线|亚洲一区二区| 99国产精品视频免费观看一公开| 久久久噜噜噜久久| 欧美+日本+国产+在线a∨观看| 国产综合色产| 久久精品国产免费看久久精品| 久久精品亚洲乱码伦伦中文 | 亚洲欧美日韩国产一区| 欧美日韩综合在线免费观看| 亚洲美女免费精品视频在线观看| 99热免费精品| 欧美日韩中文字幕日韩欧美| 一本久久a久久精品亚洲| 亚洲在线网站| 国产欧美日韩一区二区三区在线| 亚洲欧美欧美一区二区三区| 久久不见久久见免费视频1| 国产亚洲成av人片在线观看桃| 亚洲在线一区二区三区| 久久久国际精品| 亚洲高清不卡av| 欧美激情在线免费观看| 一区二区三区产品免费精品久久75 | 久久激情中文| 久久一区欧美| 亚洲国产日韩欧美综合久久 | 在线亚洲自拍| 久久精品欧美| 91久久精品国产91久久| 欧美日产在线观看| 亚洲一区二区三区影院| 久久综合99re88久久爱| 亚洲国产你懂的| 欧美日韩一本到| 欧美中文字幕第一页| 亚洲黄一区二区三区| 亚洲自拍16p| 狠狠噜噜久久| 欧美久久综合| 久久国产色av| 亚洲乱码国产乱码精品精98午夜| 欧美中文字幕精品| 日韩亚洲一区在线播放| 国产一区二区按摩在线观看| 欧美国产日本| 欧美在线亚洲在线| 日韩午夜免费视频| 欧美wwwwww| 欧美一区三区三区高中清蜜桃| 亚洲国产日韩欧美在线图片| 国产精品一区毛片| 欧美激情亚洲自拍| 久久国产综合精品| 亚洲一区二区三区欧美| 亚洲福利精品| 久久久水蜜桃| 欧美一区综合| 一区二区三区视频在线看| 韩国av一区二区三区| 国产精品久久久久久久久久尿| 蜜桃av一区二区三区| 欧美一区亚洲二区| 亚洲少妇自拍| 亚洲久久视频| 亚洲欧洲一级| 亚洲电影第三页| 欧美77777| 美日韩精品视频| 久久嫩草精品久久久精品一 |