I am trying to do the following: inside my appDelegate application, I am setting a cookie. After that, I try to read this cookie using JavaScript from webapp. Is it possible? Because I can't get it to work ...
This is my code in an iOS app:
NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionary];
[cookieProperties setObject:@"test" forKey:NSHTTPCookieName];
[cookieProperties setObject:@"yes" forKey:NSHTTPCookieValue];
[cookieProperties setObject:self.siteURL forKey:NSHTTPCookieDomain];
[cookieProperties setObject:self.siteURL forKey:NSHTTPCookieOriginURL];
[cookieProperties setObject:@"/" forKey:NSHTTPCookiePath];
[cookieProperties setObject:@"0" forKey:NSHTTPCookieVersion];
[cookieProperties setObject:[[NSDate date] dateByAddingTimeInterval:9629743] forKey:NSHTTPCookieExpires];
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
And in my JavaScript, I use the jquery.cookie plugin to write and read cookies. But there is nothing ... This is my code:
cookieValue = $.cookie("test");
alert(cookieValue);
The warning has an “object object” in the body and should be set to “yes”, which I installed in my application.
Do you guys think this is possible?
Thank!
source
share