ios - Set NSHTTPCookieExpires manually -
i want set nshttpcookie
in nshttpcookiestorage
.
for doing that, creating cookie & adding nshttpcookiestorage
shown below:-
nsdictionary *propertiesdevice = [nsdictionary dictionarywithobjectsandkeys: @"http://www.sample.com/", nshttpcookiedomain, @"/", nshttpcookiepath, @"somecookiename", nshttpcookiename, @"mycookievalue", nshttpcookievalue, timestamp,nshttpcookieexpires,nil]; nshttpcookie *cookiedevice = [nshttpcookie cookiewithproperties:propertiesdevice]; [[nshttpcookiestorage sharedhttpcookiestorage]setcookie:cookiedevice];
all properties of nshttpcookie
sets expected, apart nshttpcookieexpires
.
[nsdate date]
, value set. problem is not in desired nshttpcookie
format of expires=tue, 15-jan-2013 21:47:38 gmt
. format of [nsdate date]
2014-06-19 12:04:00 +0000
. when seek alter format of nsdate
using nsdateformatter
, output nsstring
. the problem no matter nsstring
set nshttpcookieexpires
key, takes null
value. though in documentation says nshttpcookieexpires
takes nsstring
or nsdate
.
apple doc:- <td>nshttpcookieexpires</td> <td>nsdate or nsstring</td> <td>no</td> <td>expiration date cookie. used version 0 cookies. ignored version 1 or greater.</td>
does have thought why not able set nsstring
value key nshttpcookieexpires
?
in case wasn't working because cloning existing cookie , nshttpcookiediscard
defined there.
removing solved problem.
there other rules can create expiration date nil
, if set valid nsdate
or nsstring
.
https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/nshttpcookie_class/
ios objective-c nshttpcookie
No comments:
Post a Comment