BOOL CookiePath::HasCookies(time_t this_time) { Cookie* ck = (Cookie*) cookie_list.First(); while (ck) { if (!ck->DiscardAtExit() && ck->Expires() > this_time) return TRUE; ck = ck->Suc(); } CookiePath* cp = (CookiePath*) FirstChild(); while (cp) { if (cp->HasCookies(this_time)) return TRUE; cp = cp->Suc(); } return FALSE; }
Cookie* CookiePath::GetCookieL(Cookie_Item_Handler *params, BOOL create) { Cookie* ck = LocalGetCookie(params->name); if (!create) return ck; if (ck) { #ifdef _ASK_COOKIE ServerName *servername = (ServerName *) params->url->GetAttribute(URL::KServerName, (const void*) 0); COOKIE_DELETE_ON_EXIT_MODE disc_mode = (servername ? servername->GetDeleteCookieOnExit(TRUE) : COOKIE_EXIT_DELETE_DEFAULT); BOOL default_disc_mode = (BOOL) g_pcnet->GetIntegerPref(PrefsCollectionNetwork::AcceptCookiesSessionOnly); if( ((default_disc_mode && disc_mode != COOKIE_NO_DELETE_ON_EXIT) || (!default_disc_mode && disc_mode == COOKIE_DELETE_ON_EXIT))&& !params->flags.discard_at_exit && !ck->DiscardAtExit()) params->flags.discard_at_exit= TRUE; #endif if(!params->flags.accept_updates) params->flags.accept_updates = ck->AcceptUpdates(); if(!params->flags.accepted_as_third_party) params->flags.accepted_as_third_party = ck->GetAcceptedAsThirdParty(); if(!params->flags.have_password) params->flags.have_password = ck->GetHavePassword(); if(!params->flags.have_authentication) params->flags.have_authentication = ck->GetHaveAuthentication(); OP_DELETE(ck); // *** Don't save an expired cookie. if(params->expire && params->expire < (time_t) (g_op_time_info->GetTimeUTC()/1000.0) ) return NULL; } ck = Cookie::CreateL(params); ck->Into(&cookie_list); return ck; }
void CookiePath::DebugWriteCookies(FILE* fp) { fprintf(fp, " "); DebugWritePath(fp); fprintf(fp, ": \n"); Cookie* ck = (Cookie*) cookie_list.First(); while (ck) { fprintf(fp, " %s=%s; %lu; %d; %lu %s\n", ck->Name(), ck->Value(), ck->Expires(), ck->Secure(), ck->GetLastUsed(), (ck->DiscardAtExit() ? "; Discard on exit" : "")); ck = ck->Suc(); } CookiePath* cp = (CookiePath*) FirstChild(); while (cp) { cp->DebugWriteCookies(fp); cp = cp->Suc(); } }