diff --git a/extensions/cookie/nsCookieService.cpp b/extensions/cookie/nsCookieService.cpp index b3311335f6bb..5dbb7c5bafea 100644 --- a/extensions/cookie/nsCookieService.cpp +++ b/extensions/cookie/nsCookieService.cpp @@ -89,6 +89,7 @@ nsresult nsCookieService::Init() if (observerService) { observerService->AddObserver(this, "profile-before-change", PR_TRUE); observerService->AddObserver(this, "profile-do-change", PR_TRUE); + observerService->AddObserver(this, "session-logout", PR_TRUE); observerService->AddObserver(this, "cookieIcon", PR_FALSE); } @@ -243,6 +244,9 @@ NS_IMETHODIMP nsCookieService::Observe(nsISupports *aSubject, const char *aTopic // The profile has aleady changed. // Now just read them from the new profile location. COOKIE_Read(); + } else if (!nsCRT::strcmp(aTopic, "session-logout")) { + // Quicklaunch exit -- need to remove session cookies. + COOKIE_RemoveSessionCookies(); } else if (!nsCRT::strcmp(aTopic, "cookieIcon")) { gCookieIconVisible = (!nsCRT::strcmp(someData, NS_LITERAL_STRING("on").get())); } diff --git a/extensions/cookie/nsCookies.cpp b/extensions/cookie/nsCookies.cpp index e2ab45d6c0a4..31bafd11bc55 100644 --- a/extensions/cookie/nsCookies.cpp +++ b/extensions/cookie/nsCookies.cpp @@ -271,6 +271,25 @@ cookie_RemoveExpiredCookies() { } } +/* Remove any session cookies from memory */ +PUBLIC void +COOKIE_RemoveSessionCookies() { + cookie_CookieStruct * cookie_s; + if (cookie_list == nsnull) { + return; + } + + for (PRInt32 i = cookie_list->Count(); i > 0;) { + i--; + cookie_s = NS_STATIC_CAST(cookie_CookieStruct*, cookie_list->ElementAt(i)); + NS_ASSERTION(cookie_s, "corrupt cookie list"); + if(!cookie_s->expires) { + cookie_list->RemoveElementAt(i); + deleteCookie((void*)cookie_s, nsnull); + } + } +} + /* checks to see if the maximum number of cookies per host * is being exceeded and deletes the oldest one in that * case diff --git a/extensions/cookie/nsCookies.h b/extensions/cookie/nsCookies.h index 3396e5fe50ea..4112cf16a88c 100644 --- a/extensions/cookie/nsCookies.h +++ b/extensions/cookie/nsCookies.h @@ -62,6 +62,7 @@ extern void COOKIE_SetCookieString(char * cur_url, nsIPrompt *aPrompter, const c extern void COOKIE_SetCookieStringFromHttp(char * cur_url, char * first_url, nsIPrompt *aPRompter, const char * set_cookie_header, char * server_date, nsIIOService* ioService, nsIHttpChannel* aHttpChannel); extern void COOKIE_RegisterPrefCallbacks(void); +extern void COOKIE_RemoveSessionCookies(); extern void COOKIE_RemoveAll(void); extern void COOKIE_DeletePersistentUserData(void); extern PRInt32 COOKIE_Count();