for(it++; it != cookie.end(); it++)
{
wsprintf(buf, "; %s=%s", it->first.c_str(),
url_escape(it->second).c_str());
WriteSz(buf);
}

これって cookie.end() にもデータはあるんだろ?

do
{
・・・処理・・・
}while(it != cookie.end()); じゃね?