注:CookieData是我的自定义对象,继承SQLitePersistentObject@interfaceCookieData:SQLitePersistentObject@property(nonatomic,retain)NSString*mname;@property(nonatomic,retain)NSString*mvalue;@property(nonatomic,retain)NSString*mdomain;@property(nonatomic,retain)NSString*mpath;@end#pragma-#pragmamarkcookie相关/***@brief保存cookie信息**登陆成功后保存*/+(void)saveCookie{for(CookieData*_din[CookieDataallObjects]){[_ddeleteObject];}NSHTTPCookieStorage*sharedHTTPCookie=[NSHTTPCookieStoragesharedHTTPCookieStorage];NSArray*_cookies=[sharedHTTPCookiecookies];for(inti=0;i<[_cookiescount];i++){NSHTTPCookie*_cookie=[_cookiesobjectAtIndex:i];CookieData*_cookieData=[[CookieDataalloc]init];_cookieData.mname=[_cookiename];_cookieData.mvalue=[_cookievalue];_cookieData.mpath=[_cookiepath];_cookieData.mdomain=[_cookiedomain];[_cookieDatasave];[_cookieDatarelease];}}/***@brief恢复cookie信息**请求weblogid时恢复*/+(void)recoverCookie{NSHTTPCookieStorage*sharedHTTPCookie=[NSHTTPCookieStoragesharedHTTPCookieStorage];NSArray*_cookiesDB=[CookieDataallObjects];for(inti=0;i<[_cookiesDBcount];i++){CookieData*_cookieData=[_cookiesDBobjectAtIndex:i];//CreateacookieNSDictionary*properties=[[[NSMutableDictionaryalloc]init]autorelease];[propertiessetValue:_cookieData.mvalueforKey:NSHTTPCookieValue];[propertiessetValue:_cookieData.mnameforKey:NSHTTPCookieName];[propertiessetValue:_cookieData.mdomainforKey:NSHTTPCookieDomain];[propertiessetValue:[NSDatedateWithTimeIntervalSinceNow:60*60]forKey:NSHTTPCookieExpires];[propertiessetValue:_cookieData.mpathforKey:NSHTTPCookiePath];NSHTTPCookie*cookie=[[[NSHTTPCookiealloc]initWithProperties:properties]autorelease];[sharedHTTPCookiesetCookie:cookie];}}