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

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 閱讀(825) 評論(2)  編輯 收藏 引用 所屬分類: browser

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

文章說的很清楚,多謝

我有一個問題:
如何為每個ie instance ie實例的 Persistent cookies cookie 指定不同的存儲目錄?  回復(fù)  更多評論
  
# re: Browsers, processes, cookies and session state
2009-04-07 00:33 | chatler
每個IE Instance該是不同的進(jìn)程吧,可以獲取進(jìn)程ID,在每個instance里建一個名稱包含進(jìn)程id的目錄名,就可以分目錄存儲了吧。  回復(fù)  更多評論
  
<2025年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用鏈接

留言簿(10)

隨筆分類(307)

隨筆檔案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

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

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>
            欧美在线观看网址综合| 午夜精品剧场| 国产精品乱码妇女bbbb| 欧美日产一区二区三区在线观看| 欧美黄在线观看| 欧美黑人多人双交| 欧美成人免费全部| 亚洲人被黑人高潮完整版| 亚洲韩国精品一区| 亚洲在线中文字幕| 久久久精品国产免大香伊| 欧美成人精品一区| 国产精品羞羞答答xxdd| 狠狠综合久久av一区二区老牛| 在线观看91精品国产麻豆| 一本色道久久综合亚洲二区三区| 亚洲欧美伊人| 欧美成人在线免费观看| 亚洲视频欧美在线| 久久综合久久综合这里只有精品| 欧美日韩另类视频| 一区二区三区在线视频播放| 日韩网站在线| 久热精品视频在线观看一区| 日韩亚洲在线观看| 久久在线免费观看| 国产精品自拍一区| 9l国产精品久久久久麻豆| 久久久久网站| 一区二区三区免费观看| 噜噜噜躁狠狠躁狠狠精品视频| 欧美午夜剧场| 亚洲精品免费在线| 久久久精品视频成人| 亚洲精品之草原avav久久| 久久精品官网| 国产麻豆日韩欧美久久| 亚洲一区二区三| 亚洲缚视频在线观看| 亚洲一区二区三区精品在线| 麻豆精品在线观看| 久久超碰97人人做人人爱| 国产精品久久久久高潮| 亚洲人成亚洲人成在线观看图片| 欧美在线一二三| 免费中文字幕日韩欧美| 欧美日韩中文字幕综合视频| 亚洲国产裸拍裸体视频在线观看乱了 | 久久午夜视频| 国产日韩欧美一区二区| 一区二区三区欧美| 亚洲国产成人tv| 久久中文字幕导航| 国产亚洲人成a一在线v站| 中日韩高清电影网| 亚洲全部视频| 欧美日韩国产成人在线91| 日韩天堂av| 亚洲欧洲视频| 欧美日韩国产一区精品一区| 欧美精品一区二区视频 | 久久久久久久久蜜桃| 国产精品人人爽人人做我的可爱| 亚洲少妇诱惑| 亚洲一区二区免费视频| 国产精品久久久久久久午夜| 午夜国产精品视频免费体验区| 一本色道久久综合亚洲精品小说| 欧美日韩国产综合新一区| 中文亚洲视频在线| 亚洲深夜福利视频| 国产日韩在线看| 久久嫩草精品久久久精品一| 久久久精品久久久久| 亚洲激情视频网站| 日韩亚洲不卡在线| 国产精品一区二区久激情瑜伽| 久久精品国产精品亚洲| 久久精品一区二区国产| 亚洲黄色成人| 中文国产成人精品| 黄色av一区| 日韩午夜精品| 国产一区二区久久精品| 亚洲国产99| 国产精品日韩在线观看| 欧美成人情趣视频| 欧美午夜影院| 欧美成人日韩| 国产精品久久久久影院亚瑟 | 在线播放日韩欧美| 亚洲人屁股眼子交8| 国产美女扒开尿口久久久| 欧美成人午夜视频| 国产精品一区毛片| 亚洲高清在线精品| 日韩午夜在线电影| 在线看片欧美| 亚洲视频一区二区在线观看 | 欧美电影在线| 国产精品人人爽人人做我的可爱| 美日韩精品视频| 欧美日韩亚洲一区| 免费看亚洲片| 国产精品视频久久一区| 欧美高清在线播放| 国产精品一区二区三区成人| 欧美激情在线狂野欧美精品| 国产欧美精品日韩区二区麻豆天美| 欧美国产激情二区三区| 国产欧美日韩精品一区| 日韩香蕉视频| 亚洲三级国产| 久久久久久久久久久一区| 欧美一区二区在线| 欧美系列一区| 亚洲午夜精品| 猛男gaygay欧美视频| 久久久精品日韩| 国产欧美日韩亚洲精品| 亚洲少妇一区| 正在播放欧美视频| 欧美h视频在线| 欧美成人四级电影| 在线观看亚洲视频| 久久久久综合网| 巨胸喷奶水www久久久免费动漫| 国产女人aaa级久久久级| 亚洲视频导航| 亚洲欧美日本精品| 欧美性做爰毛片| 中文精品视频一区二区在线观看| 99在线热播精品免费| 欧美精品自拍偷拍动漫精品| 亚洲国产激情| 亚洲精品综合精品自拍| 欧美高清视频www夜色资源网| 亚洲二区精品| 夜夜爽www精品| 欧美日韩一二区| 91久久精品国产| 亚洲精品一区中文| 欧美精品自拍| 制服丝袜亚洲播放| 欧美一区二区视频网站| 黄色成人小视频| 欧美成人dvd在线视频| 亚洲精品一区二区三区不| 在线视频一区二区| 国产精品视频午夜| 久久激情久久| 亚洲国产精品成人va在线观看| 亚洲精选91| 99国内精品久久| 在线亚洲欧美视频| 国产嫩草影院久久久久| 久久精品免费看| 亚洲国产mv| 亚洲欧美日韩精品久久久久| 国产日本亚洲高清| 狼人社综合社区| 一本久道久久综合婷婷鲸鱼| 午夜视频在线观看一区二区三区| 国内成人精品2018免费看| 欧美电影免费观看大全| 亚洲影院污污.| 亚洲福利国产精品| 午夜精品剧场| 亚洲精品在线观看免费| 国产精品黄色在线观看| 久久久久久91香蕉国产| 亚洲麻豆av| 久久手机精品视频| 亚洲午夜精品一区二区| 激情另类综合| 欧美日韩中文另类| 老色鬼精品视频在线观看播放| 在线一区亚洲| 欧美国产三级| 久久国产精品久久国产精品 | 噜噜噜久久亚洲精品国产品小说| 日韩一级二级三级| 黑人巨大精品欧美一区二区 | 久久综合九色综合久99| 亚洲一区二区三区在线看| 亚洲精品美女免费| 国产一区二区三区在线观看视频 | 欧美中文字幕在线视频| 亚洲欧洲精品一区二区| 久久一综合视频| 亚洲欧美日韩国产一区二区| 亚洲日本激情| 伊人久久婷婷| 国产一区二区三区不卡在线观看| 欧美三级韩国三级日本三斤| 欧美激情一区在线观看| 久久综合狠狠综合久久激情| 性欧美在线看片a免费观看| 一本大道久久a久久精品综合| 亚洲国产免费|