bug 129819, release session cookies when using quicklaunch, r=sgehani, sr=darin, a=rjesup@wgate.com, atd=jaimie

This commit is contained in:
morse%netscape.com 2002-04-09 01:06:02 +00:00
parent 7b66ac993f
commit 3715753691
3 changed files with 24 additions and 0 deletions

View File

@ -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()));
}

View File

@ -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

View File

@ -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();