Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Delete / Disable WebView Cookies?

Anyone know of anyway to clear the cookies for a WebView, or disable them altogether? Trying to create a stateless login pop-up using a WebView and the fact that it's storing login credential cookies is breaking everything.

I believe there's a database with cookie information in it, but it's undocumented.

— asked May 21st 2010 by Alan McConnell
  • cookies
  • iphone
  • webview

3 Answers

  • This is code I wrote to get all the cookies from a webView.

    var webView = Ti.UI.createWebView({url:"http://www.google.com"});
        var cookies = webView.evalJS("document.cookie").split(";"); 
        Ti.API.info( "# of cookies -> " + cookies.length  );
        for (i = 0; i <= cookies.length - 1; i++) {
                Ti.API.info( "cookie -> " + cookies[i] );

    You could modify it to get the cookie name as it loops through and then delete the cookie like this

    webView.evalJS("document.cookie = cookie_name += "=; expires=-1";");
    — answered November 17th 2010 by Aaron Saunders
    1 Comment
    • Thanks for your answer.
      And do you have any trick to set the cookies before the page is loaded (so the page is loaded with the cookies we previously manually set)?

      — commented February 14th 2011 by Thomas Dall'Agnese
  • you can like this


    even if using webView.
    it will works

    — answered August 12th 2013 by Daehyeon Shin
  • You could make a function inside the html of the WebView, that cleans the cookies.

    If you need the cleaning to be done only once you could trigger this function with a Titanium event, only when the app starts.

    — answered May 21st 2010 by Dan Tamas
    1 Comment
    • Entra gratis a las mejores discotecas de Madrid http://www.midnightvip.com

      — commented June 14th 2013 by a a
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.