If you close a Web browser window that is hosted in Microsoft Visual Basic, Microsoft Foundation Classes (MFC), or other types of applications while you keep the process alive, you may lose cookies that are issued without an expiration date. Cookies that are issued without an expiration date are known as session cookies. If you lose sessions cookies, you lose your Microsoft Active Server Pages (ASP) and Microsoft ASP.NET session state.
Back to the top
Internet Explorer ends the Internet session when you close the last browser window in the logon session.
Back to the top
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Back to the top
Make sure that the Internet session is not ended when you close the last window. Set the
DISPID_AMBIENT_OFFLINEIFNOTCONNECTED ambient property to
VARIANT_TRUE so that Internet Explorer does not check an internal session count variable. For example, use the following sample code in an MFC application:
#include <idispids.h>
BOOL CGenhtmlviewView::OnAmbientProperty(COleControlSite* pSite, _
DISPID dispid, VARIANT* pvar)
{
USES_CONVERSION;
if (dispid == DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)
{
pvar->vt = VT_BOOL;
pvar->boolVal = VARIANT_TRUE;
return TRUE;
}
return CHtmlView::OnAmbientProperty(pSite, dispid, pvar);
}
Back to the top
Internet Explorer maintains a session count that tracks the number of instances of the browser window in the logon session. Whenever the logon session count becomes 0, the process that closes the last window ends the Internet session by calling the
InternetSetOption function (
INTERNET_OPTION_END_BROWSER_SESSION). This technique causes the symptoms that can appear in two common situations:
| • | When you host the WebBrowser control
Run an application, and then open a window that hosts the WebBrowser control. When you locate a Web site that maintains a session and then close the window of that session, if that window was the last window that displayed the WebBrowser control in all of the logon session, your memory cookies disappear, including your session ID. In the same running process, when you reopen that window and return to the site, you are in a different session. |
| • | When you start Internet Explorer from a file-based URL instead of an HTTP-based URL
You may lose your session state if you follow these steps:| 1. | Set your home page to C:\MyDoc\MyHome.htm. | | 2. | Make sure that you have no active instances of either Internet Explorer or the WebBrowser control. | | 3. | Click a URL that maintains a session ID to start Internet Explorer, and then locate a Web site. | | 4. | Open a new window, which becomes the second window in the logon session, and then close the window.
NOTE: You may not lose your session state if your computer is on for several hours. Various conditions can cause Internet Explorer to lose track of its session count over the time of the logon session.
|
|
The problem does not occur if another instance of Internet Explorer is running in another process. Internet Explorer maintains its session count for all of the computer. Sometimes, you may not experience the problems that are described in this article. This is because some situations cause Internet Explorer not to decrement the session count. The longer your logon session, the more likely you are not to experience these problems.
Back to the top
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
300895 (http://support.microsoft.com/kb/300895/EN-US/) BUG: Session ID Lost When New Window Opened
Back to the top