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

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

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

文章說的很清楚,多謝

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

常用鏈接

留言簿(10)

隨筆分類(307)

隨筆檔案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

  • cloudward
  • 感覺這個(gè)博客還是不錯(cuò),雖然做的東西和我不大相關(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

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲欧洲日韩在线| 久久精品成人一区二区三区蜜臀| 日韩午夜激情av| 亚洲欧洲日韩女同| 亚洲三级免费| 一片黄亚洲嫩模| 欧美91视频| 国产精品国产三级国产专区53| 欧美精品在线观看91| 国产精品高清在线| 国产午夜久久久久| 亚洲黄色一区二区三区| 亚洲一区二区免费在线| 久久久久久久久久久成人| 欧美激情导航| 亚洲视频在线看| 久久婷婷亚洲| 国产精品每日更新| 91久久精品视频| 性欧美video另类hd性玩具| 美女视频黄 久久| 99精品欧美一区二区三区| 欧美怡红院视频| 欧美日韩黄色大片| 精品成人在线视频| 亚洲图中文字幕| 欧美高清视频一区| 亚洲欧美卡通另类91av| 欧美国产极速在线| 国产亚洲欧美日韩一区二区| 亚洲精品美女| 狂野欧美激情性xxxx欧美| 夜夜嗨av色综合久久久综合网| 久久久久久亚洲精品中文字幕| 欧美日韩亚洲综合一区| 亚洲成色999久久网站| 欧美在线观看一区二区三区| 欧美国产一区二区| 欧美影院久久久| 国产精品欧美激情| 亚洲无线一线二线三线区别av| 美女脱光内衣内裤视频久久影院 | 欧美高清视频在线观看| 国产精品毛片在线看| 日韩一级成人av| 免费av成人在线| 香蕉久久久久久久av网站| 欧美精品一区二区视频| 在线观看欧美日韩国产| 久久国产视频网| 亚洲专区免费| 国产乱码精品一区二区三| 亚洲伊人伊色伊影伊综合网| 亚洲精品国产精品乱码不99按摩| 久久夜色撩人精品| 在线看国产日韩| 欧美搞黄网站| 嫩草伊人久久精品少妇av杨幂| 极品尤物一区二区三区| 久久色中文字幕| 久久久久久久久久久久久女国产乱 | 亚洲影院一区| 欧美小视频在线观看| 亚洲一区二区三区四区在线观看 | 国产精品久久国产精品99gif | 国内精品免费午夜毛片| 欧美在线观看一二区| 亚洲欧美经典视频| 国产自产2019最新不卡| 久久综合色一综合色88| 蜜臀91精品一区二区三区| 亚洲精品一区在线| 日韩午夜免费| 国产美女精品| 老色鬼久久亚洲一区二区| 久热精品在线| 日韩视频免费观看高清完整版| 亚洲精品美女91| 国产精品一区免费视频| 久久久之久亚州精品露出| 乱中年女人伦av一区二区| 99re热精品| 亚洲综合精品四区| 伊人成年综合电影网| 亚洲国产一区二区精品专区| 欧美日韩视频专区在线播放 | 狠狠色狠狠色综合日日小说| 老司机67194精品线观看| 美女诱惑黄网站一区| 亚洲一区在线免费观看| 欧美在线观看网址综合| 亚洲三级电影全部在线观看高清| 亚洲色图综合久久| 亚洲国产欧美日韩另类综合| 99re8这里有精品热视频免费| 国产午夜精品理论片a级大结局| 欧美成人激情视频免费观看| 国产精品高潮呻吟久久| 欧美国产免费| 国产日本欧美一区二区| 亚洲三级网站| 在线欧美日韩国产| 亚洲欧美国内爽妇网| 亚洲欧洲一区| 久久av一区二区三区| 亚洲天堂视频在线观看| 美腿丝袜亚洲色图| 久久精品亚洲国产奇米99| 欧美日韩亚洲国产一区| 猛干欧美女孩| 国产性天天综合网| 亚洲制服av| 老司机aⅴ在线精品导航| 欧美日韩在线免费视频| 美女视频网站黄色亚洲| 国产精品美女一区二区| 亚洲精品久久久久久久久久久| 有码中文亚洲精品| 欧美主播一区二区三区美女 久久精品人 | 亚洲国产美女精品久久久久∴| 亚洲最新中文字幕| 亚洲精品免费观看| 久久综合狠狠综合久久激情| 欧美一级久久| 国产精品久久久久久久久久免费| 亚洲精品久久久久久一区二区| 狠狠做深爱婷婷久久综合一区| 午夜精品网站| 久久精品亚洲精品国产欧美kt∨| 国产久一道中文一区| 亚洲伊人伊色伊影伊综合网| 中文精品视频| 欧美性猛交xxxx乱大交蜜桃 | 亚洲少妇自拍| 欧美在线免费看| 国产亚洲欧美一区二区三区| 小辣椒精品导航| 久久午夜色播影院免费高清| 国内成+人亚洲+欧美+综合在线| 欧美中文字幕在线播放| 久久婷婷麻豆| 在线观看欧美| 欧美高清自拍一区| 日韩视频免费观看高清在线视频| 日韩亚洲欧美中文三级| 欧美日韩国产在线播放| 日韩午夜av在线| 午夜精品久久99蜜桃的功能介绍| 国产精品yjizz| 亚洲欧美日韩国产精品 | 久久一区中文字幕| 亚洲国产欧美国产综合一区| 欧美大片在线观看一区| 夜夜精品视频| 久久久精品日韩| 91久久线看在观草草青青| 欧美顶级艳妇交换群宴| 在线一区观看| 久久亚洲精品中文字幕冲田杏梨| 亚洲电影激情视频网站| 欧美激情网友自拍| 亚洲在线视频免费观看| 久久综合伊人77777尤物| 亚洲精品中文字幕有码专区| 欧美体内谢she精2性欧美| 亚洲欧美影音先锋| 亚洲缚视频在线观看| 亚洲欧美视频一区二区三区| 一区在线免费观看| 欧美日韩另类综合| 久久精品九九| 99国产精品久久久久老师| 欧美日韩在线视频一区| 亚洲电影免费观看高清| 亚洲综合国产| 亚洲电影在线免费观看| 国产精品国产馆在线真实露脸| 久久精品在线| 亚洲图片在线| 亚洲国产精品va在线看黑人 | 国产精品人人做人人爽人人添| 久久亚洲免费| 午夜一区二区三区在线观看| 91久久夜色精品国产九色| 久久九九全国免费精品观看| 一区二区三区久久久| 亚洲福利在线看| 国产亚洲一区在线| 欧美日韩一区在线观看视频| 久久亚洲一区二区| 欧美影院成人| 亚洲一区在线直播| 一本不卡影院| 亚洲三级视频| 亚洲高清视频的网址| 美国十次成人| 久热国产精品| 久久综合五月| 久久久国产精品亚洲一区| 午夜亚洲精品|