I want to set a NSHTTPCookie in the NSHTTPCookieStorage.
For doing that, I am creating a cookie & adding it to the NSHTTPCookieStorage as 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 the properties of the NSHTTPCookie sets as expected, apart from the NSHTTPCookieExpires.
- If I pass
[NSDate date], then the value is set. But the problem is it is not in the desiredNSHTTPCookieformat ofExpires=Tue, 15-Jan-2013 21:47:38 GMT. The format of[NSDate date]is2014-06-19 12:04:00 +0000. - When I try to change the format of
NSDateusingNSDateFormatter, the output isNSString. - The problem is that no matter what
NSStringI set toNSHTTPCookieExpireskey, it takesnullvalue.
Though in the documentation it says that NSHTTPCookieExpires takes NSString or NSDate.
From Apple Doc:-
<td>NSHTTPCookieExpires</td>
<td>NSDate or NSString</td>
<td>NO</td>
<td>Expiration date for the cookie. Used only for version 0
cookies. Ignored for version 1 or greater.</td>
Does anyone have any idea as to why we are not able to set NSString value for the key NSHTTPCookieExpires?