pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<legend id='bN0ZH'><style id='bN0ZH'><dir id='bN0ZH'><q id='bN0ZH'></q></dir></style></legend>

    1. <small id='bN0ZH'></small><noframes id='bN0ZH'>

        • <bdo id='bN0ZH'></bdo><ul id='bN0ZH'></ul>
        <i id='bN0ZH'><tr id='bN0ZH'><dt id='bN0ZH'><q id='bN0ZH'><span id='bN0ZH'><b id='bN0ZH'><form id='bN0ZH'><ins id='bN0ZH'></ins><ul id='bN0ZH'></ul><sub id='bN0ZH'></sub></form><legend id='bN0ZH'></legend><bdo id='bN0ZH'><pre id='bN0ZH'><center id='bN0ZH'></center></pre></bdo></b><th id='bN0ZH'></th></span></q></dt></tr></i><div class="mc6syak" id='bN0ZH'><tfoot id='bN0ZH'></tfoot><dl id='bN0ZH'><fieldset id='bN0ZH'></fieldset></dl></div>

      1. <tfoot id='bN0ZH'></tfoot>

        NSHTTPCookieStorage 的共享實例不保留 cookie

        Shared instance of NSHTTPCookieStorage does not persist cookies(NSHTTPCookieStorage 的共享實例不保留 cookie)
        • <i id='iADZ4'><tr id='iADZ4'><dt id='iADZ4'><q id='iADZ4'><span id='iADZ4'><b id='iADZ4'><form id='iADZ4'><ins id='iADZ4'></ins><ul id='iADZ4'></ul><sub id='iADZ4'></sub></form><legend id='iADZ4'></legend><bdo id='iADZ4'><pre id='iADZ4'><center id='iADZ4'></center></pre></bdo></b><th id='iADZ4'></th></span></q></dt></tr></i><div class="8couqu4" id='iADZ4'><tfoot id='iADZ4'></tfoot><dl id='iADZ4'><fieldset id='iADZ4'></fieldset></dl></div>
            <tbody id='iADZ4'></tbody>

              <bdo id='iADZ4'></bdo><ul id='iADZ4'></ul>
              <tfoot id='iADZ4'></tfoot>

                <small id='iADZ4'></small><noframes id='iADZ4'>

                <legend id='iADZ4'><style id='iADZ4'><dir id='iADZ4'><q id='iADZ4'></q></dir></style></legend>
                1. 本文介紹了NSHTTPCookieStorage 的共享實例不保留 cookie的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在開發(fā)一個應(yīng)用程序,在該應(yīng)用程序中服務(wù)器將 cookie 交給我來識別用戶.

                  I'm developing an application where the server hands me a cookie to identify the user.

                  我的連續(xù)請求需要該 cookie 才能獲得用戶期望的響應(yīng).我無法理解的是 NSHTTPCookieStorage 的共享實例如何以及何時丟失其 cookie.

                  My successive requests need to have that cookie to have the response that the user expects. What I can't understand is how and when the shared instance of NSHTTPCookieStorage loses its cookies.

                  我使用的第一個解決方案是在應(yīng)用程序終止時將 cookie 從我的服務(wù)器存檔并保存到用戶默認(rèn)值,然后在應(yīng)用程序啟動時從我的服務(wù)器中清除現(xiàn)有的 cookie,并重置我存儲的那些.在開發(fā)過程中,我沒有遇到任何問題,因為調(diào)試會話非常短,通常不需要將應(yīng)用程序置于后臺.

                  The first solution I used is to archive and save the cookies from my server to user defaults on application terminations then clear existing ones from my server on application launch and reset the ones I stored. Through the developing process I didn't encounter problems as the sessions for debugging are very short and didn't usually need to put the app in background.

                  在 Beta 測試期間,問題開始了.我?guī)淼募记墒遣粌H在應(yīng)用程序終止時保存 cookie,而且在將這些 cookie 交還給我的 API 調(diào)用之后保存.并且不僅在應(yīng)用啟動時加載保存的 cookie,而且在應(yīng)用返回前臺時加載.

                  During beta testing, troubles started. The hack I came with is to save the cookies not only on application termination but also after the API calls that hand me back these cookies. And to load the saved cookies not only on app launch but also when the app returns to foreground.

                  NSHTTPCookieStorage 共享實例如何擺脫這些 cookie 以及處理它的最佳實踐是什么,因為它是我的應(yīng)用程序的重要組成部分,如果沒有更有經(jīng)驗的開發(fā)人員支持,我無法相信這種被黑的解決方案.

                  How come the NSHTTPCookieStorage share instance gets rid of these cookies and what's the best practice to deal with it as it's a vital part of my app and I can't trust such a hacked solution if not backed up by more experienced developers.

                  提前感謝您的回答

                  以下是保存/讀取/清除cookies的方法

                  Here are the methods to save/read/clear the cookies

                  -(void)saveStoredCookies
                  {
                      NSURL *httpUrl = @"http://myServer.com";
                      NSURL *httpsUrl = @"https://myServer.com";
                  
                      NSArray *httpCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpUrl];
                      NSData *httpCookiesData = [NSKeyedArchiver archivedDataWithRootObject:httpCookies];
                      [[NSUserDefaults standardUserDefaults] setObject:httpCookiesData forKey:@"savedHttpCookies"];
                  
                      NSArray *httpsCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpsUrl];
                      NSData *httpsCookiesData = [NSKeyedArchiver archivedDataWithRootObject:httpsCookies];
                      [[NSUserDefaults standardUserDefaults] setObject:httpsCookiesData forKey:@"savedHttpsCookies"];
                  
                      [[NSUserDefaults standardUserDefaults] synchronize];
                  }
                  
                  -(void)readStoredCookies
                  {
                      //clear, read and install stored cookies
                      NSURL *httpUrl = @"http://myServer.com";
                      NSURL *httpsUrl = @"https://myServer.com";
                  
                      NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpUrl];
                      for (NSHTTPCookie *cookie in cookies) {
                          [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
                      }
                      cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpsUrl];
                      for (NSHTTPCookie *cookie in cookies) {
                          [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
                      }
                  
                      NSData *httpCookiesData = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedHttpCookies"];
                      if([httpCookiesData length]) {
                          NSArray *savedCookies = [NSKeyedUnarchiver unarchiveObjectWithData:httpCookiesData];
                          for (NSHTTPCookie *cookie in savedCookies) {
                              [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
                          }       
                      }
                      NSData *httpsCookiesData = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedHttpsCookies"];
                      if([httpsCookiesData length]) {
                          NSArray *savedCookies = [NSKeyedUnarchiver unarchiveObjectWithData:httpsCookiesData];
                          for (NSHTTPCookie *cookie in savedCookies) {
                              [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
                          }       
                      }
                  }
                  
                  -(void)clearStoredCookies
                  {
                      NSURL *httpUrl = @"http://myServer.com";
                      NSURL *httpsUrl = @"https://myServer.com";
                      NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpUrl];
                      for (NSHTTPCookie *cookie in cookies) {
                          [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
                      }
                      cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpsUrl];
                      for (NSHTTPCookie *cookie in cookies) {
                          [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
                      }
                  }
                  

                  推薦答案

                  解決了!

                  經(jīng)過一些簡單的調(diào)試后,我發(fā)現(xiàn)問題出在我在 cookiesForURL: 中使用的 url.我只是開始使用 cookies 屬性,現(xiàn)在它工作正常.

                  After some simple debugging I found out that the problem was with the url I was using in cookiesForURL:. I simply started using cookies property and now it works fine.

                  這篇關(guān)于NSHTTPCookieStorage 的共享實例不保留 cookie的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標(biāo)已經(jīng)包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))

                    <tbody id='XFtj6'></tbody>
                  <tfoot id='XFtj6'></tfoot>

                        • <bdo id='XFtj6'></bdo><ul id='XFtj6'></ul>

                            <legend id='XFtj6'><style id='XFtj6'><dir id='XFtj6'><q id='XFtj6'></q></dir></style></legend>

                            <small id='XFtj6'></small><noframes id='XFtj6'>

                            <i id='XFtj6'><tr id='XFtj6'><dt id='XFtj6'><q id='XFtj6'><span id='XFtj6'><b id='XFtj6'><form id='XFtj6'><ins id='XFtj6'></ins><ul id='XFtj6'></ul><sub id='XFtj6'></sub></form><legend id='XFtj6'></legend><bdo id='XFtj6'><pre id='XFtj6'><center id='XFtj6'></center></pre></bdo></b><th id='XFtj6'></th></span></q></dt></tr></i><div class="wuu4swk" id='XFtj6'><tfoot id='XFtj6'></tfoot><dl id='XFtj6'><fieldset id='XFtj6'></fieldset></dl></div>

                          1. 主站蜘蛛池模板: TTCMS自助建站_网站建设_自助建站_免费网站_免费建站_天天向上旗下品牌 | 千淘酒店差旅平台-中国第一家针对TMC行业的酒店资源供应平台 | 四川实木门_成都实木门 - 蓬溪聚成门业有限公司 | 滑板场地施工_极限运动场地设计_滑板公园建造_盐城天人极限运动场地建设有限公司 | 安平县鑫川金属丝网制品有限公司,声屏障,高速声屏障,百叶孔声屏障,大弧形声屏障,凹凸穿孔声屏障,铁路声屏障,顶部弧形声屏障,玻璃钢吸音板 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 北京公司注册_代理记账_代办商标注册工商执照-企力宝 | 活性炭-蜂窝-椰壳-柱状-粉状活性炭-河南唐达净水材料有限公司 | 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 河南中专学校|职高|技校招生-河南中职中专网 | 深圳激光打标机_激光打标机_激光焊接机_激光切割机_同体激光打标机-深圳市创想激光科技有限公司 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 | 成都思迪机电技术研究所-四川成都思迪编码器 | 菏泽知彼网络科技有限公司| 哈尔滨治「失眠/抑郁/焦虑症/精神心理」专科医院排行榜-京科脑康免费咨询 一对一诊疗 | 日本细胞免疫疗法_肿瘤免疫治疗_NK细胞疗法 - 免疫密码 | 作文导航网_作文之家_满分作文_优秀作文_作文大全_作文素材_最新作文分享发布平台 | 轴承振动测量仪电箱-轴承测振动仪器-测试仪厂家-杭州居易电气 | pos机办理,智能/扫码/二维码/微信支付宝pos机-北京万汇通宝商贸有限公司 | 上海地磅秤|电子地上衡|防爆地磅_上海地磅秤厂家–越衡称重 | 合肥抖音SEO网站优化-网站建设-网络推广营销公司-百度爱采购-安徽企匠科技 | OpenI 启智 新一代人工智能开源开放平台| 脱硝喷枪-氨水喷枪-尿素喷枪-河北思凯淋环保科技有限公司 | 吊篮式|移动式冷热冲击试验箱-二槽冷热冲击试验箱-广东科宝 | 玻璃钢罐_玻璃钢储罐_盐酸罐厂家-河北华盛节能设备有限公司 | 爆炸冲击传感器-无线遥测传感器-航天星百科 | 压砖机_电动螺旋压力机_粉末成型压力机_郑州华隆机械tel_0371-60121717 | 涂层测厚仪_光泽度仪_uv能量计_紫外辐照计_太阳膜测试仪_透光率仪-林上科技 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 桐城新闻网—桐城市融媒体中心主办 | 天命文免费算命堂_自助算命_自由算命系统_长文周易 | 常州减速机_减速机厂家_常州市减速机厂有限公司 | 空气能采暖,热泵烘干机,空气源热水机组|设备|厂家,东莞高温热泵_正旭新能源 | 展厅装修公司|企业展厅设计|展厅制作|展厅搭建—广州展厅装饰公司 | 哈希PC1R1A,哈希CA9300,哈希SC4500-上海鑫嵩实业有限公司 | 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 天津市能谱科技有限公司-专业的红外光谱仪_红外测油仪_紫外测油仪_红外制样附件_傅里叶红外光谱技术生产服务厂商 | 篷房|仓储篷房|铝合金篷房|体育篷房|篷房厂家-华烨建筑科技官网 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 轴流风机-鼓风机-离心风机-散热风扇-罩极电机,生产厂家-首肯电子 | 浙江上沪阀门有限公司| 拉力机-万能试验机-材料拉伸试验机-电子拉力机-拉力试验机厂家-冲击试验机-苏州皖仪实验仪器有限公司 |