sDate = cookie_ParseDate(server_date);
if (server_date) { sDate = cookie_ParseDate(server_date); } else { sDate = time(NULL); }
COOKIE_SetCookieStringFromHttp(char * curURL, char * setCookieHeader, char * server_date) {  /* allow for multiple cookies separated by newlines */   char *newline = PL_strchr(setCookieHeader, '\n');   if(newline) {     *newline = '\0';     COOKIE_SetCookieStringFromHttp(curURL, setCookieHeader, server_date);     *newline = '\n';     COOKIE_SetCookieStringFromHttp(curURL, newline+1, server_date);     return;   }  /* If the outputFormat is not PRESENT (the url is not going to the screen), and not   *  SAVE AS (shift-click) then    *  the cookie being set is defined as inline so we need to do what the user wants us   *  to based on his preference to deal with foreign cookies. If it's not inline, just set   *  the cookie.   */  char *ptr=NULL;  time_t gmtCookieExpires=0, expires=0, sDate;#ifdef later // We need to come back and fix this.  - Neeti  if(CLEAR_CACHE_BIT(outputFormat) != FO_PRESENT &&      CLEAR_CACHE_BIT(outputFormat) != FO_SAVE_AS) {    if (cookie_GetBehaviorPref() == COOKIE_DontAcceptForeign) {      // the user doesn't want foreign cookies, check to see if its foreign       char * curSessionHistHost = 0;      char * theColon = 0;      char * curHost = cookie_ParseURL(curURL, GET_HOST_PART);      History_entry * shistEntry = SHIST_GetCurrent(&context->hist);      if (shistEntry) {        curSessionHistHost = cookie_ParseURL(shistEntry->address, GET_HOST_PART);      }       if(!curHost || !curSessionHistHost) {        PR_FREEIF(curHost);        PR_FREEIF(curSessionHistHost);        return;      }      /* strip ports */      theColon = PL_strchr(curHost, ':');      if(theColon) {        *theColon = '\0';      }      theColon = PL_strchr(curSessionHistHost, ':');      if(theColon) {        *theColon = '\0';      }      /* if it's foreign, get out of here after a little clean up */      if(!cookie_SameDomain(curHost, curSessionHistHost)) {        PR_FREEIF(curHost);        PR_FREEIF(curSessionHistHost);        return;      }      PR_FREEIF(curHost);      PR_FREEIF(curSessionHistHost);    }  }#endif /* later */  /* Determine when the cookie should expire. This is done by taking the difference between    * the server time and the time the server wants the cookie to expire, and adding that    * difference to the client time. This localizes the client time regardless of whether or   * not the TZ environment variable was set on the client.   */  /* Get the time the cookie is supposed to expire according to the attribute*/  ptr = PL_strcasestr(setCookieHeader, "expires=");  if(ptr) {    char *date =  ptr+8;    char origLast = '\0';    for(ptr=date; *ptr != '\0'; ptr++) {      if(*ptr == ';') {        origLast = ';';        *ptr = '\0';        break;      }    }    expires = cookie_ParseDate(date);    *ptr=origLast;  }  sDate = cookie_ParseDate(server_date);  if( sDate && expires ) {    if( expires < sDate ) {      gmtCookieExpires=1;    } else {      gmtCookieExpires = expires - sDate + time(NULL);      // if overflow       if( gmtCookieExpires < time(NULL)) {        gmtCookieExpires = (((unsigned) (~0) << 1) >> 1); // max int       }    }  }  cookie_SetCookieString(curURL, setCookieHeader, gmtCookieExpires);}