1

I'm trying to create a simple webview app of my website, I load the url, make some actions (saving cookies) without problems but, when I close and re-open my app, all cookies are destroyed. Where is the problem? Thanks.

super.viewDidLoad()

let urlString = "http://my.url"

let url = NSURL(string: urlString)

let request = NSMutableURLRequest(URL: url!)

webView.loadRequest(request)
Mirko Brombin
  • 1,002
  • 3
  • 12
  • 34
  • 1
    Can you add the bit of code that actually sets or retrieves the cookie? – AmitM Sep 04 '15 at 15:53
  • I save the cookie in website not in the app.I've created a php script in my site that save a cookie when you visit the page, I open the website in the webview and the script save the cookie and see me it ($_COOKIE["ok"]) but when I close the app, I lose the cookie. – Mirko Brombin Sep 04 '15 at 15:55
  • In any case, looking at the code would help. Are you setting a proper expiration date while creating the cookie? – AmitM Sep 07 '15 at 03:06
  • No, but the code is only this.. the problem is with every website – Mirko Brombin Sep 07 '15 at 06:35
  • 1
    See if this helps you http://stackoverflow.com/questions/2662530/iphone-nshttpcookie-is-not-saved-across-app-restarts – AmitM Sep 07 '15 at 12:03
  • I'm using swift but.. I've already converted and used it and.. not work – Mirko Brombin Sep 07 '15 at 16:31

0 Answers0