let urlEnconded = sessionId!.stringByAddingPercentEncodingWithAllowedCharacters(
NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]").invertedSet)!
let properties = [NSHTTPCookieDomain: WebURL.URL_MIGME_SERVER,
NSHTTPCookiePath: "\\",
NSHTTPCookieName: "eid",
NSHTTPCookieValue: urlEnconded + MigboClient.cookiePrefix]
if let cookie = NSHTTPCookie(properties: properties) {
NSHTTPCookieStorage.sharedHTTPCookieStorage().setCookie(cookie)
System.setShareProperties(DefaultConfig.SHARE_SYS_COOKIES, value: properties)
}
//使用
var url = NSURL(string: "yourUrl")mutableRequest = NSMutableURLRequest(URL:url)
var cookies = NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies as! [NSHTTPCookie]
var headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies)
mutableRequest!.allHTTPHeaderFields = headers
self._webview.loadRequest(mutableRequest ?? NSURLRequest(URL:url))
沒有留言:
張貼留言