I find Vimeo iOS native app can set cookies to mobile Safari. How does it do?
Repo steps:
1, Install Vimeo iOS native app on an iOS device.
2, Open this Vimeo iOS native app and then sign in with your Vimeo account.
3, Open mobile Safari and then open web page "https://vimeo.com/". You find you are not signed in Vimeo.
4, Open Vimeo iOS native app and then click on the "Help (question mark)" icon in the left navigation bar. You will see that Vimeo's web page help center is opened via UIWebView. And then you can close this help center.
5, Open mobile Safari and then open web page "https://vimeo.com/". You find you are signed in Vimeo.
Thank you.
As shown in this question, you can set a cookie using the NSHTTPCookieStorage
class.
EDIT:
As Kitsune pointed out, the docs state that this will not work between applications in iOS like it does in OSX.
I do not have time to test this right now, but perhaps you can set a cookie using javascript and the stringByEvaluatingJavaScriptFromString
method of UIWebView
and it will be shared? Here is a function that I found on the internet which could be called:
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}